Re: Regex with ASCII and non-ASCII chars
- From: Peter Otten <__peter__@xxxxxx>
- Date: Wed, 31 Jan 2007 14:47:23 +0100
TOXiC wrote:
How I can do a regex match in a string with ascii and non ascii chars
for example:
regex = re.compile(r"(ÿÿ?ð?öÂty)", re.IGNORECASE)
match = regex.search("ÿÿ?ð?öÂty")
if match:
result = match.group()
print result
else:
result = "No match found"
print result
it return "no match found" even if the two string are equal.
For equal strings you should get a match:
<_sre.SRE_Match object at 0x401e0a68>re.compile("Zäöü", re.IGNORECASE).search("yadda zäöü yadda")
zäöüprint _.group()
For case ignorance your best bet is unicode:
<_sre.SRE_Match object at 0x401e09f8>re.compile(u"äöü", re.IGNORECASE|re.UNICODE).search(u"ÄÖÜ")
Peter
.
- Follow-Ups:
- Re: Regex with ASCII and non-ASCII chars
- From: TOXiC
- Re: Regex with ASCII and non-ASCII chars
- References:
- Regex with ASCII and non-ASCII chars
- From: TOXiC
- Regex with ASCII and non-ASCII chars
- Prev by Date: Re: Help needed on config files
- Next by Date: Re: grp.struct_group bug ?
- Previous by thread: Regex with ASCII and non-ASCII chars
- Next by thread: Re: Regex with ASCII and non-ASCII chars
- Index(es):