Q:

Python program to search for regular expression in string using search() method

0

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

The search() method is used to search for the occurrence of regex patterns in the string.

Syntax:

regex.match(regexPattern, string, flag)

Let's take an example to understand the problem,

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

Output:
Search Item 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 our solution

import re

myString = "learn python programming language at includehelp"

searchObject = re.search( r'(.*) python (.*?) .* ', myString, re.M|re.I)
if searchObject:
    print("Item found! ")
else:
    print("No Item are found!")

Output:

Item 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