Re: Newbie backreference question

2005-06-30 Thread paulm
George Sakkis <[EMAIL PROTECTED]> wrote: > > Did you have a look at my other reply ? It's still the same, just > change the regexp: > > import re > a = 'test string two' > b = re.match(r'test \w{2}(.+)', a, re.DOTALL).group(1) > print b > > By the way, if you want to catch any single character (

Re: Newbie backreference question

2005-06-30 Thread George Sakkis
"paulm" <[EMAIL PROTECTED]> wrote: > No, sorry - my bad. I am looking to assign the > backreference to another variable so it can be treated > seperately. So perhaps: > > $a = 'test string two'; > $a =~ /test \w{2}([\W\w]+)/; > $b = $1; > print $b . "\n"; > > producing "ring two". > > I have read

Re: Newbie backreference question

2005-06-30 Thread paulm
Larry Bates <[EMAIL PROTECTED]> wrote: > a='test string' > print a.split()[:-1] > > I'm assuming that you want the last space separated word? > > Larry Bates > > > paulm wrote: >> Hi, >> In perl I can do something like: >> >> $a = 'test string'; >> $a =~ /test (\w+)/; >> $b = $1; >> prin

Re: Newbie backreference question

2005-06-30 Thread George Sakkis
> Hi, > In perl I can do something like: > > $a = 'test string'; > $a =~ /test (\w+)/; > $b = $1; > print $b . "\n"; > > and my output would be "string". > > How might this snippet be written in python? > > Thanks to all... import re a = 'test string' b = re.match(r'test (\w+)', a).group(1) print

Re: Newbie backreference question

2005-06-30 Thread Robert Kern
paulm wrote: > Hi, > In perl I can do something like: > > $a = 'test string'; > $a =~ /test (\w+)/; > $b = $1; > print $b . "\n"; > > and my output would be "string". > > How might this snippet be written in python? http://docs.python.org/lib/module-re.html -- Robert Kern [EMAIL P

Re: Newbie backreference question

2005-06-30 Thread Larry Bates
a='test string' print a.split()[:-1] I'm assuming that you want the last space separated word? Larry Bates paulm wrote: > Hi, > In perl I can do something like: > > $a = 'test string'; > $a =~ /test (\w+)/; > $b = $1; > print $b . "\n"; > > and my output would be "string". > > Ho

Newbie backreference question

2005-06-30 Thread paulm
Hi, In perl I can do something like: $a = 'test string'; $a =~ /test (\w+)/; $b = $1; print $b . "\n"; and my output would be "string". How might this snippet be written in python? Thanks to all... -- http://mail.python.org/mailman/listinfo/python-list