Regular Expression Syntax Help

Raja Raman Sundararajan ram0812 at hotmail.com
Wed Feb 8 03:16:22 EST 2006


Oh! yes you can use re for that.
You just need to change the pattern a bit

I did not understand where the "title" will be so I have ignored it,
but I got something below which will be helpful for you

>>> value = """name:asasasasas\nrequest: play\ntitle"""
>>> reg = re.compile('Name:.*\\nrequest:.....', re.IGNORECASE)
>>> re.findall(reg, value)
['name:asasasasas\nrequest: play']
>>> value2 = """name:asasasasas\nrequest: next\ntitle"""
>>> reg = re.compile('Name:.*\\nrequest:.....', re.IGNORECASE)
>>> re.findall(reg, value2)
['name:asasasasas\nrequest: next']
>>>




More information about the Python-list mailing list