Sometimes, while working with Python, we can have a problem we have list of regex and we need to check a particular string matches any of the available regex in list. Let’s discuss a way in which this task can be performed.
Method : Using join regex + loop +
This task can be performed using combination of above functions. In this, we create a new regex string by joining all the regex list and then match the string against it to check for match using match() with any of the element of regex list.
The original list : ['gee*', 'gf*', 'df.*', 're'] Does string match any of regex in list ? : True
- Python | Check if suffix matches with any string in given list
- Python | Program that matches a word containing 'g' followed by one or more e's using regex
- Python | Find all close matches of input string from a list
- Python | Check if given string can be formed by concatenating string elements of list
- Python | Check if string ends with any string in given list
- 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 | Check whether the input is Floating point number or not
- Python | Check if any String is empty in list
- Python Regex to extract maximum numeric value from a string
- Python - Check if string starts with any element in list
- Python Regex - Program to accept string starting with vowel
- Python Regex | Program to accept string ending with alphanumeric character
- Python | Convert List of String List to String List
- Python | Check if a list exists in given list of lists
- Python - Check List elements from Dictionary List
- Python | Convert list of string to list of list
- Python | Convert mixed data types tuple list to string list
- Python | Convert list of string into sorted list of integer
- Python | Convert list of numerical string to list of Integers
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.