<div>Thanks very much for your reply.</div>
<div>What I mean is that I would like to use the ascii number in a regular expression pattern.</div>
<div>For instance, if I want to substitute the occurrences of character 'a' for the character 'b' in a string, instead of doing this:</div>
<div> </div>
<div>re.subn('a','b','aaaa')</div>
<div> </div>
<div>I'd like to specify the ascii number of a (which is 97)</div>
<div>I tried converting 97 to hexadecimal (with hex()) and tried this</div>
<div> </div>
<div>re.subn(''\0x61,'b','aaaa')</div>
<div> </div>
<div>but it doesnt work.</div>
<div>I need this because I'm working on non printable characters.</div>
<div> </div>
<div>Thanks a lot</div>
<div><br><br> </div>
<div class="gmail_quote">On Tue, Apr 28, 2009 at 12:45 PM, Chris Rebert <span dir="ltr"><<a href="mailto:clp2@rebertia.com">clp2@rebertia.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="h5">On Tue, Apr 28, 2009 at 4:05 AM, jorma kala <<a href="mailto:jjkk73@gmail.com">jjkk73@gmail.com</a>> wrote:<br>> Hi,<br>><br>> How can I use the ascii number of a character in a regular expression<br>
> (module re) instead of the character itself?<br>> Thanks very much<br><br></div></div>I refer you to the chr() and ord() built-in functions, which can<br>certainly be used to solve your problem, though they are not<br>
regex-specific in application.<br><a href="http://docs.python.org/library/functions.html" target="_blank">http://docs.python.org/library/functions.html</a><br><br>Cheers,<br>Chris<br><font color="#888888">--<br><a href="http://blog.rebertia.com/" target="_blank">http://blog.rebertia.com</a><br>
</font></blockquote></div><br>