RegExp question

Ben C spamspam at spam.eggs
Tue Apr 11 16:12:38 EDT 2006


On 2006-04-11, Michael McGarry <michael.mcgarry at gmail.com> wrote:
> Tim,
>
> for some reason that does not seem to do the trick.
>
> I am testing it with grep. (i.e., grep -e '(and|or|xor)\s*#' myfile)

Try with grep -P, which means use perl-compatible regexes as opposed to
POSIX ones. I only know for sure that -P exists for GNU grep.

I assumed it was a Python question! Unless you're testing your Python
regex with grep, not realizing they're different.

Perl and Python regexes are (mostly?) the same.

I usually grep -P because I know Python regexes better than any other
ones.



More information about the Python-list mailing list