RegExp question

Tim Chase python.list at tim.thechases.com
Tue Apr 11 16:23:40 EDT 2006


> I am testing it with grep. (i.e., grep -e '(and|or|xor)\s*#' myfile)

Well, you asked for the python regexp...different 
environments use different regexp parsing engines.  Your 
response is akin to saying "the example snippet of python 
code you gave me doesn't work in my Pascal program".

For grep:

grep '\(and\|or\|xor\)[[:space:]]*#' myfile

For Vim:

:g/\(and\|or\|xor\)\s*#/

The one I gave originally is a python regexp, and thus 
should be tested within python, not grep or vim or emacs or 
sed or whatever.

It's always best to test in the real 
environment...otherwise, you'll get flakey results.

-tkc









More information about the Python-list mailing list