How do I parse this ? regexp ? [slighly OT]

Peter Hansen peter at engcorp.com
Thu Apr 28 20:53:14 EDT 2005


Simon Dahlbacka wrote:
>>>>>safetyChecker = re.compile(r"^[-\[\]0-9,. ]*$")
> 
> ..doesn't the dot (.) in your character class mean that you are allowing
> EVERYTHING (except newline?)

The re docs clearly say this is not the case:

'''
[]
     Used to indicate a set of characters. Characters can be listed 
individually, or a range of characters can be indicated by giving two 
characters and separating them by a "-". Special characters are not 
active inside sets.
'''

Note the last sentence in the above quotation...

-Peter



More information about the Python-list mailing list