How to escape # hash character in regex match strings
504crank at gmail.com
504crank at gmail.com
Wed Jun 10 10:47:13 EDT 2009
I've encountered a problem with my RegEx learning curve -- how to
escape hash characters # in strings being matched, e.g.:
>>> string = re.escape('123#abc456')
>>> match = re.match('\d+', string)
>>> print match
<_sre.SRE_Match object at 0x00A6A800>
>>> print match.group()
123
The correct result should be:
123456
I've tried to escape the hash symbol in the match string without
result.
Any ideas? Is the answer something I overlooked in my lurching Python
schooling?
More information about the Python-list
mailing list