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 Regex - Program to accept string starting with vowel
- Python Regex | Program to accept string ending with alphanumeric character
- 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
- Python | Find all close matches of input string from a list
- Pattern matching in Python with Regex
- Python | Parse a website with regex and urllib
- Find all the patterns of “1(0+)1” in a given string using Python Regex
- The most occurring number in a string using Regex in python
- Python Regex to extract maximum numeric value from a string
- Python regex | Check whether the input is Floating point number or not
- 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
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.