problem with regex
Rob Wolfe
blue99 at interia.pl
Fri Jul 28 09:46:27 EDT 2006
abcd wrote:
> not sure why this passes:
>
>
> >>> regex = r'[A-Za-z]:\\([^/:\*\?"<>\|])*'
> >>> p = re.compile(regex)
> >>> p.match('c:\\test')
> <_sre.SRE_Match object at 0x009D77E0>
> >>> p.match('c:\\test?:/')
> <_sre.SRE_Match object at 0x009D7720>
> >>>
>
> the last example shouldnt give a match
If you want to learn RE I suggest to use great tool redemo.py (tk app).
Then you can play with regular expressions to find the result
you are looking for.
It can be found in Python 2.4 in Tools\Scripts.
Regards,
Rob
More information about the Python-list
mailing list