Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

What is regular expressions in python?

Description

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

Process
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 (“”, match.group())
else:
print (“No match”)
#initialize search object
search = re.search( r’Python’, string, re.M|re.I)
if search:
print (“Serach success “, search.group())
else:
print (“Nothing found”)

Screenshots
What is regular expressions in python