Simple (?) Regular Expression Question

Steve Zatz slzatz at hotmail.com
Sun Jan 18 18:45:31 EST 2004


Is '@' a special character in regular expressions?  I am asking
because I don't understand the following:

>>> import re
>>> s = ' @'
>>> re.sub(r'\b@','*',s)
' @'
>>> s = ' a'
>>> re.sub(r'\ba','*',s)
' *'

Have googled atsign and regular expressions but have not found
anything useful.  System is Win XP, Python 2.3.3. Any help would be
appreciated.



More information about the Python-list mailing list