Python 3 – Regular Expressions

Regular expressions are patterns that help in filtering the text possessing them, and also in extracting portions of data that match the patterns, for further use.

  • The patterns are built using special characters.
  • Python uses¬†re¬†package to deal with regular expressions.

Example

import re

pattern='for'

text='information'

if re.search(pattern, text):

    print('Yes')

Leave a Reply

Your email address will not be published. Required fields are marked *