Q:

Python program to check whether a regular expression is present in string or not

0

The regular expression in Python is a search pattern formed by a sequence of characters.

The match() method is used to check whether the given pattern is matched to the string. It is defined using the re library.

Syntax:

regex.match(regexPattern, string, flag (optional) )

Let's take an example to understand the problem,

Input:
string = "learn python programming language at includehelp" ; pattern = '(.*) at (.*?)'

Output:
Match Found

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to illustrate the working of out solution

import re

myString = "learn python programming language at includehelp"

matchObj = re.match( r'(.*) python (.*?) .* ', myString, re.M|re.I)

if matchObj:
    print("Match Found ")
else:
    print("No Matches are found")

Output:

Match Found

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now