Re: Using ascii numbers in regular expression

2009-04-30 Thread MRAB
Lie Ryan wrote: MRAB wrote: You're almost there: re.subn('\x61','b','') or better yet: re.subn(r'\x61','b','') Wouldn't that becomes a literal \x61 instead of "a" as it is inside raw string? Yes. The re module will understand the \x sequence within a regular expression.

Re: Using ascii numbers in regular expression

2009-04-30 Thread Lie Ryan
MRAB wrote: You're almost there: re.subn('\x61','b','') or better yet: re.subn(r'\x61','b','') Wouldn't that becomes a literal \x61 instead of "a" as it is inside raw string? -- http://mail.python.org/mailman/listinfo/python-list

Re: Using ascii numbers in regular expression

2009-04-28 Thread MRAB
jorma kala wrote: Thanks very much for your reply. What I mean is that I would like to use the ascii number in a regular expression pattern. For instance, if I want to substitute the occurrences of character 'a' for the character 'b' in a string, instead of doing this: re.subn('a','b','')

Re: Using ascii numbers in regular expression

2009-04-28 Thread Chris Rebert
On Tue, Apr 28, 2009 at 4:58 AM, jorma kala wrote: > Thanks very much for your reply. > What I mean is that I would like to use the ascii number in a regular > expression pattern. > For instance, if I want to substitute the occurrences of character 'a' for > the character 'b' in a string, instead

Re: Using ascii numbers in regular expression

2009-04-28 Thread jorma kala
Thanks very much for your reply. What I mean is that I would like to use the ascii number in a regular expression pattern. For instance, if I want to substitute the occurrences of character 'a' for the character 'b' in a string, instead of doing this: re.subn('a','b','') I'd like to specify t

Re: Using ascii numbers in regular expression

2009-04-28 Thread Chris Rebert
On Tue, Apr 28, 2009 at 4:05 AM, jorma kala wrote: > Hi, > > How can I use the ascii number of a character in a regular expression > (module re) instead of the character itself? > Thanks very much I refer you to the chr() and ord() built-in functions, which can certainly be used to solve your pro

Using ascii numbers in regular expression

2009-04-28 Thread jorma kala
Hi, How can I use the ascii number of a character in a regular expression (module re) instead of the character itself? Thanks very much -- http://mail.python.org/mailman/listinfo/python-list