Javascript equivalent "match" in python

I have a method to extract all "words" from a string in javascript:

mystring.toLowerCase().match(/[a-z]+/g);

      

I would like to convert the same logic (create an array of "words" from my string), but in python. How can I achieve this?

+3


source to share


1 answer


Use findall()

which is similar to String.prototype.match()

.



import re
regex = r"[a-z]+"
matches = re.findall(regex, strToScan)

      

+3


source







All Articles