…the demethylation of codeine into morphine and read that pyridine HCl is will only cleave the methyl ether, leaving the other ether intact. How does pyridine HCl demethylate ethers? I'm guessing the pyridine HCl complex is a much weaker acid than free HCl but I can't understand how it is an acid. Is it the pyridinium ion that acts as the acid?
There are two parts to this reaction. Because the chloride is present as its salt, heating will not result in the loss of chloride as would happen with HCl. Chloride can be a good nucleophile to do a substitution reaction on the methyl group. (I not sure it would be the primary nucleophile either.)
The second is a question of equilibrium. The only difference between pyridinium and hydronium ion in a reaction with hydroxide is the pH of the reaction. Both reagents are proton donors. The equilibrium between hydroxide or water occurs at a higher pH with pyridinium ion than hydronium ion. This simply means that the equilibrium greatly favors pyridinium ion over protonation of codeine. Substitution is only going to occur from the protonated codeine. Since the concentration of (oxy) protonated codeine will be low, the reaction will be slower.
I am also guessing that with the low concentrations of protonation of the methyl ether oxygen means the reaction is heated. Furthermore, codeine looks as though it could be easily dehydrated or subject to an acid catalyzed elimination. Using pyridinium chloride would be a convenient method to keep the pH from going too low. It can also be a convenient way to weigh out HCl.
Back to the reaction, codeine has a more basic nitrogen than pyridine and codeine•HCl is more likely the actual acid. Pyridine itself may be the nucleophile in this demethylation. I would suggest an analogy is how dimethylaminopyridine or pyridine are used as catalysts in acylation reactions by forming intermediate pyridinium salts, pyridine may form an intermediate methyl pyridinium salt. This could decompose to methyl chloride and pyridine resulting in pyridine being only catalytic in this reaction.
There are many reactions in which the product occurs from only a small amount of intermediate forming in an equilibrium. If you draw out the steps in an enamine formation, then you may have to draw an intermediate in which protonation of an sp3 oxygen must occur in preference to an sp3 nitrogen in order to eliminate neutral water under acid catalyzed conditions. Another is a Claisen condensation. The equilibrium between ethoxide, ethanol, and an ester like ethyl acetate greatly favors deprotonation of ethanol (pKa 16) over ethyl acetate (pKa 26). The success of the reaction shows that deprotonation must be occurring to some small extent even though the reaction path must overcome the less favorable enolization of the ester.