[regex] Basic rewriting

Gilles Ganault nospam at nospam.com
Tue Nov 20 21:24:03 EST 2007


Hello

	I've been reading tutorials on regexes in Python, but I still
don't get it:

========
#!/usr/bin/python

#myscript.py 0123456789

import sys,re

#Turn 0123456789 into 01.23.45.67.89
p = re.compile('(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)')
phone = p.sub('\1.\2.\3.\4.\5',sys.argv[1])
print phone
========

=> Python displays "...." instead. Any idea what I'm doing wrong?

Thank you.



More information about the Python-list mailing list