[Tutor] Newbie: Passing variable into re.compile

John Fouhy john at fouhy.net
Thu Mar 30 01:09:30 CEST 2006


On 30/03/06, Jerome Jabson <jjabson at yahoo.com> wrote:
> import re
>
> arg1 = '10"
>
> p = re.compile(r + arg1 + '\.(\d+\.\d+\.\d+)')

Have a look at string substitutions :-)  ---
http://docs.python.org/lib/typesseq-strings.html

p = re.compile(r'%s\.(\d+\.\d+\.\d+)' % arg1)

--
John.


More information about the Tutor mailing list