The Vilsmeier–Haack formylation of pyrrole

Dimethylformamide reacts with phosphorus oxychloride through the carbonyl oxygen; loss of dichlorophosphate leaves a chloroiminium ion, the Vilsmeier reagent. It is a weak electrophile, which does not attack benzene but does attack electron-rich rings: pyrroles, furans, indoles, anilines and phenols.
Pyrrole attacks it at C2 and, after losing a proton, forms a stable conjugated iminium salt that can be isolated. Hydrolysis with aqueous sodium acetate releases pyrrole-2-carbaldehyde in yields above 80%. With other amides (for example N,N-dimethylacetamide) ketones are obtained.