python regex character group matches
Fredrik Lundh
fredrik at pythonware.com
Wed Sep 17 11:15:54 EDT 2008
Steven D'Aprano wrote:
>> Assuming that you want to find runs of \uXXXX escapes, simply use
>> non-capturing parentheses:
>>
>> pat = re.compile(u"(?:\\\u[0-9A-F]{4})")
>
> Doesn't work for me:
>
>>>> pat = re.compile(u"(?:\\\u[0-9A-F]{4})")
it helps if you cut and paste the right line... here's a better version:
pat = re.compile(r"(?:\\u[0-9A-F]{4})+")
</F>
More information about the Python-list
mailing list