Simple regular-expression example. : Search : Regular Expressions PYTHON TUTORIALS


PYTHON TUTORIALS » Regular Expressions » Search »

 

Simple regular-expression example.


import re

# list of strings to search and expressions used to search
testStrings = "Hello World""Hello world!""hello world" ]
expressions = "hello""Hello""world!" ]

# search every expression in every string
for string in testStrings:
   for expression in expressions:
      if re.searchexpression, string ):
         print expression, "found in string", string
      else:
         print expression, "not found in string", string
   print



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Regular Expressions
» Search