I have a method for extracting all the "words" from a string in javascript:
mystring.toLowerCase().match(/[a-z]+/g);
I'd like to convert that same logic (create an array of "words" from my string), but in python. How can I achieve that?
Use findall()
, which is similar to String.prototype.match()
.
import re
regex = r"[a-z]+"
matches = re.findall(regex, strToScan)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.