how to match whole word

Fredrik Lundh fredrik at pythonware.com
Wed Jul 16 17:23:48 EDT 2008


John S wrote:

 > Not sure why you picked \A and \Z -- they are only useful if you are
 > using the re.M flag.

Well, they're aliases for ^ and $ in "normal" mode, at least for strings 
that don't end with a newline.

> re.I is the same as re.IGNORECASE. More than one option may be OR'ed
> together. There's no such thing as "re.O" in Python.  I can understand
> where you get the idea, as there is an 'o' modifier for REs in Perl.

His code did

     opts.ignore_case and re.I or 0

which is the same as "re.I if opts.ignore_case else 0" in Python 2.5, 
where 0 is a zero and not an O.

</F>




More information about the Python-list mailing list