Re: help in converting perl re to python re

2006-03-03 Thread Joel Hedlund
Hi the perl code finds a line that matches something like tag1sometext\tag1 in the line and then assign $variable the value of sometext No, but if you use a closing /tag1 instead of \tag1 it does. You had me scratching my head for a while there. :-) This should do it in python:

Re: help in converting perl re to python re

2006-03-03 Thread Sybren Stuvel
Joel Hedlund enlightened us with: regexp = re.compile(r(tag1)(.*)/\1) I'd go for regexp = re.compile(r(tag1)(.*?)/\1) Otherwise this: line = tag1sometext/tag1tag1othertext/tag1 match = regexp.search(line) will result in 'sometext/tag1tag1othertext' Sybren -- The problem with the world is

Re: help in converting perl re to python re

2006-03-03 Thread Joel Hedlund
I'd go for regexp = re.compile(r(tag1)(.*?)/\1) Indeed. I second that. /Joel -- http://mail.python.org/mailman/listinfo/python-list

Re: help in converting perl re to python re

2006-03-03 Thread Mitja Trampus
i have some regular exp code in perl that i want to convert to python. if $line =~ m#(tag1)(.*)/\1# { $variable = $2; } regexp = re.compile(r(tag1)(.*)/\1) line = tag1sometext/tag1 match = regexp.search(line) if match: variable = match.group(2) Or, if you prefer

help in converting perl re to python re

2006-03-02 Thread eight02645999
hi i have some regular exp code in perl that i want to convert to python. if $line =~ m#(tag1)(.*)/\1# { $variable = $2; } the perl code finds a line that matches something like tag1sometext\tag1 in the line and then assign $variable the value of sometext how can i do an