I want to thank you for using the re module for this. Especially in case of case sensitivity.
We use the re.IGNORECASE parameter when compiling a regular expression for use in production environments with large amounts of data.
>>> import re >>> m = ['isalnum','isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'ISALNUM', 'ISALPHA', 'ISDIGIT', 'ISLOWER', 'ISSPACE', 'ISTITLE', 'ISUPPER'] >>> >>> >>> pattern = re.compile('is') >>> >>> [word for word in m if pattern.match(word)] ['isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper']
However, always try to use the in operator to compare strings, as described in detail in this post.
faster re-match-or-ul
Also described in detail in one of the best books on the study of python with
idiomatic python
eleijonmarck Jan 07 '19 at 16:51 2019-01-07 16:51
source share