[Tutor] Regular expression to match \f in groff input?
Alan Gauld
alan.gauld at btinternet.com
Thu Aug 21 20:35:05 CEST 2008
"Bill Campbell" <bill at celestial.net> wrote
> to get regular expressions to match the font change sequences in
> *roff input (e.g. \fB for bold, \fP to revert to previous font).
> The re library maps r'\f' to the single form-feed character (as
> it does other common single-character sequences like r'\n').
I think all you need is an extra \ to escape the \ character in \f
> This does not work in puthon:
>
> s = re.sub(r'\f[1NR]', '</emphasis>, sinput)
Try
s = re.sub(r'\\f[1NR]', '</emphasis>, sinput)
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list