Go4Expert (http://www.go4expert.com/)
-   Python (http://www.go4expert.com/articles/python-tutorials/)
-   -   Regex in Python (http://www.go4expert.com/articles/regex-in-python-t2062/)

pradeep 29Nov2006 17:30

Regex 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

 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"
     for k, grp in enumerate(oMatches.groups()):
         print "Group %d matched %r<br/>" % (k+1, grp)

Scripting 19Jul2010 22:58

Re: Regex in Python
it seems interstingly.

All times are GMT +5.5. The time now is 19:34.