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:
>
>
>
>
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.
__
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