Here is an example of a failed match where None is returned : Match : Regular Expressions PYTHON TUTORIALS


PYTHON TUTORIALS » Regular Expressions » Match »

 

Here is an example of a failed match where None is returned


import re

m = re.match('foo', 'bar')# pattern does not match string
if m is not None: m.group()(1-line version of ifclause)

m = re.match('foo', 'food on the table') # match succeeds
print m.group()

print re.match('foo', 'food on the table').group()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Regular Expressions
» Match