re.search slashes

pyluke user at example.net
Sat Feb 4 11:08:33 EST 2006


I'm parsing LaTeX document and want to find lines with equations blocked 
by "\[" and "\]", but not other instances of "\[" like "a & b & c \\[5pt]"

so, in short, I was to match "\[" but not "\\]"

to add to this, I also don't want lines that start with comments.


I've tried:
check_eq = re.compile('(?!\%\s*)\\\\\[')
check_eq.search(line)

this works in finding the "\[" but also the "\\["

so I would think this would work
check_eq = re.compile('(?![\%\s*\\\\])\\\\\[')
check_eq.search(line)

but it doesn't.  Any tips?



More information about the Python-list mailing list