Research breakthrough possible @S-Logix

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • +91- 81240 01111

Social List

What is regular expressions in python?


To see what is regular expression and how to use it in python3.

Regular expressions

  special sequence of characters that helps you match or find other strings or sets of strings.

   The module re provides full support for regular expressions in python.

Regular expression match():

  This function attempts to match RE pattern to string with optional flags.

Regular expression search():

  This function searches for first occurrence of RE pattern within string with optional flags.

Sample Code

#Regular expression module
import re
#input string
string = “Python is a scripting language”;
#initialize match object
match = re.match( r’Pythons’, string, re.M|re.I)
if match:
print (“”,
print (“No match”)
#initialize search object
search = r’Python’, string, re.M|re.I)
if search:
print (“Serach success “,
print (“Nothing found”)

What is regular expressions in python