I want to filter strings in a list based on a regular expression.
Is there something better than [x for x in list if r.match(x)]
?
You can create an iterator in Python 3.x or a list in Python 2.x by using:
filter(r.match, list)
To convert the Python 3.x iterator to a list, simply cast it; list(filter(..))
.