我有一个从 javascript 中的字符串中提取所有“单词”的方法:
mystring.toLowerCase().match(/[a-z]+/g);
我想转换相同的逻辑(从我的字符串创建一个“单词”数组),但在 python 中。我怎样才能做到这一点?
最佳答案
使用findall()
,类似于 String.prototype.match()
。
import re
regex = r"[a-z]+"
matches = re.findall(regex, strToScan)
关于javascript - 相当于 Python 中的 Javascript "match",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27391607/