>> 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 = "<tag1>sometext</tag1>" > match = regexp.search(line) > if match: > variable = match.group(2) Or, if you prefer shorter, quick-and-dirty syntax closer to perl's approach: match = re.search(r"<(tag1)>(.*)</\1>", line) if match: variable = match.group(2) -- http://mail.python.org/mailman/listinfo/python-list