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 | Check if string matches regex list
- Python Regex - Program to accept string starting with vowel
- Python Regex | Program to accept string ending with alphanumeric character
- Python program to remove Nth occurrence of the given word
- Python program for word guessing game
- 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
- Verbose in Python Regex
- Name validation using IGNORECASE in Python Regex
- Pattern matching in Python with Regex
- Python Regex: re.search() VS re.findall()
- 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
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.
Improved By : ManasChhabra2