Regex in Python

pradeep's Avatar author of Regex in Python
This is an article on Regex in Python in Python.
Well, I was trying to use regular expressions in Python. I wrote a small script, so I thought I'll will post it and make it open for discussion. As I learn more I'll keep them posted too, and if anyone has any comments please do let me know.

Code: Python
#!/usr/bin/python
 
 import re
 
 print "Content-Type: text/html\n\n"
 
 regx = re.compile(r"([A-C])([a-x])?") # Should match either A,B or C, and another character between a-x after tht
 
 sTest = "An Apple A Day Keeps The Doctor Away from Vitamin C"
 
 print "Trying a match..<br/>"
 
 oMatches = regx.match(sTest)
 if not oMatches:
     print "There were no matches"
 else:
     for k, grp in enumerate(oMatches.groups()):
         print "Group %d matched %r<br/>" % (k+1, grp)
Scripting likes this
John Hoder
19Jul2010,22:58   #2
Scripting's Avatar
it seems interstingly.