Reg Exp in Python tutorial

General discussion on technical and managerial topics
no avatar
Posts: 1
Joined: Mon May 13, 2013 5:10 pm

Reg Exp in Python tutorial

by khl » Mon May 13, 2013 5:17 pm


The given example ( ... ssions.htm) doesn't seem to work.

This matches a previously matched group again:
([Pp])ython&\1ails Match "python&rails or Python&Rails"

Put this in to the previous Cats example
import re

line = "Python&Rails";

matchObj = re.match( r'([Pp])ython&(\1ails)', line, re.M|re.I)

if matchObj:
print " : ",
print " : ",
print " : ",
print "No match!!"

it shows
No match!!
[Finished in 0.1s]

Change the line to "Python&Pails" then it's Okay.

Return to General Discussion