1.找出一句话中所有以大写字母或数字开头的词。
import re
data = "Today is Saturday. I see 20 cars in the parking area. nOt q2."
result = re.findall(r"\b[A-Z0-9]\w*", data)
print(result)
注意匹配单词开头是\b,^是匹配行的开头。
1.找出一句话中所有以大写字母或数字开头的词。
import re
data = "Today is Saturday. I see 20 cars in the parking area. nOt q2."
result = re.findall(r"\b[A-Z0-9]\w*", data)
print(result)
注意匹配单词开头是\b,^是匹配行的开头。