Given a string, the task is to check if that string contains any g followed by one or more e’s in it, otherwise, print No match.
Input : geeks for geeks Output : geeks geeks Input : graphic era Output : No match
Approach : Firstly, make a regular expression (regex) object that matches a word which contains ‘g’ followed by one or more e’s, then pass a string in the
findall method. This method returns the list of the matched strings. Loop through the list and print each matched word.
\w – represent Any letter, numeric digit, or the underscore character.
* means zero or more occurrence of the character.
+ means one or more occurrence of the character.
Below is the implementation :
- Python program for word guessing game
- Python program to remove Nth occurrence of the given word
- Python | Program to implement Jumbled word game
- Python | Check if suffix matches with any string in given list
- Pattern matching in Python with Regex
- Python | Find all close matches of input string from a list
- Python | Parse a website with regex and urllib
- The most occurring number in a string using Regex in python
- Find all the patterns of “1(0+)1” in a given string using Python Regex
- Python Regex to extract maximum numeric value from a string
- Regex in Python to put spaces between words starting with capital letters
- Python regex to find sequences of one upper case letter followed by lower case letters
- Generating Word Cloud in Python | Set 2
- Generating Word Cloud in Python
- Python | Reverse each word in a sentence
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.