Q:

Python program to check the presence of substring in given string - Regex Example

0

Python programming language supports regular expression. RegEx is a sequence of characters for matching with other strings.

Here, we are given an expression and key. And we have a program to check whether the key is present in the expression.

Let's take an example to illustrate the working of our solution,

Input:
key = "includehelp" ; expression = "learn programming at includehelp"

Output:
True

We will use the in method which checks for the presence of a substring in the string and returns a boolean value based on the comparison.

All Answers

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

Python code:

expression = "this is a sample regular expression data"
print("Expression : ",expression)
key = "sample"
print("Is [sample] present in expression : ",key in expression)

Output:

Expression :  this is a sample regular expression data
Is [sample] present in expression :  True

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now