Re: just out of curiosity...

Jan-Hein Buhrman (Jan-Hein.Buhrman@cwi.nl)
Fri, 03 Jul 1992 10:59:05 +0200

Terence M. Brannon <brannon@jove.cs.caltech.edu>:
>Target to search for is `\section{Using Nitroglycerin in the Home}',
>at the start of a line.
>
>sect_regex = regex.compile('^.*\\section{\(.+\)+}.*$') works, but
>sect_regex = regex.compile('^\\section{\(.+\)+}.*$') doesn't work.
I'm not a regular python user (that's an understatement), but I
recognize the type of confusion from Emacs' elisp programming.

For python, the string '\\' contains one (1) backslash (`\'). So
regexp.compile just sees the sequence `\sectio<...etc.>', and depending
on the kind of regexp library, mode, and program you are working with,
the backslash might be thrown away, generates an error, or means "match
a character whose syntax belongs to the code `e' (see Emacs syntax
codes)."

I tested the next part of code, and it works:

sect_regex = regex.compile('^\\\\section{\\(.+\\)}.*$')

Watch also the double backslashes before the braces. Hope this helps.

-- Jan-Hein Buhrman -- CWI, Amsterdam -- <jh@cwi.nl> --
NFS server (amd:109) not responding still trying
NFS server (amd:109) ok
/ufs/jh/lib/mottos: No such file or directory