Re: [Tutor] Newbie: Passing variable into re.compile

2006-03-29 Thread Kent Johnson
Jerome Jabson wrote: > Hello, > > > > I’m having trouble trying to pass a variable into > re.compile(), using the “r” option. Let’s say I > have the following: > > > > import re > > arg1 = ‘10” > > p = re.compile(r + arg1 + '\.(\d+\.\d+\.\d+)') > > > > This works if I do: > > > >

Re: [Tutor] Newbie: Passing variable into re.compile

2006-03-29 Thread John Fouhy
On 30/03/06, Jerome Jabson <[EMAIL PROTECTED]> 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. __

[Tutor] Newbie: Passing variable into re.compile

2006-03-29 Thread Jerome Jabson
Hello, I’m having trouble trying to pass a variable into re.compile(), using the “r” option. Let’s say I have the following: import re arg1 = ‘10” p = re.compile(r + arg1 + '\.(\d+\.\d+\.\d+)') This works if I do: p = re.compile(r ‘10\.(\d+\.\d+\.\d+)') Is there