Re: Regex with ASCII and non-ASCII chars

2007-01-31 Thread TOXiC
On 31 Gen, 17:30, "TOXiC" <[EMAIL PROTECTED]> wrote: > It wont work with utf-8,iso or ascii... I think the best way is to search hex value in the file stream but I tryed (in the regex) \hxx but it don't work... -- http://mail.python.org/mailman/listinfo/python-list

Re: Regex with ASCII and non-ASCII chars

2007-01-31 Thread TOXiC
It wont work with utf-8,iso or ascii... -- http://mail.python.org/mailman/listinfo/python-list

Re: Regex with ASCII and non-ASCII chars

2007-01-31 Thread Peter Otten
TOXiC wrote: > Thx it work perfectly. > If I want to query a file stream? > > file = open(fileName, "r") > text = file.read() > file.close() Convert the bytes read from the file to unicode. For that you have to know the encoding, e. g. file_encoding = "utf-8" # replace with th

Re: Regex with ASCII and non-ASCII chars

2007-01-31 Thread TOXiC
Thx it work perfectly. If I want to query a file stream? file = open(fileName, "r") text = file.read() file.close() regex = re.compile(u"(ÿÿ‹ð…öÂ)", re.IGNORECASE) match = regex.search(text) if (match): result = match.group() print result WritePatch

Re: Regex with ASCII and non-ASCII chars

2007-01-31 Thread Peter Otten
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: > resul

Regex with ASCII and non-ASCII chars

2007-01-31 Thread TOXiC
Hello everybody. 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 fou