2024-09-27 09:21:53 发布
网友
我试图将string与mypattern匹配,但不知何故我没有得到正确的结果。你能指出我哪里错了吗?你知道吗
string
mypattern
import re mypattern = '_U_[R|S]_data.csv' string = 'X003_U_R_data.csv' re.match(mypattern, string)
我喜欢先编译regex语句。然后我做任何我想做的匹配/搜索。你知道吗
mypattern = re.compile(ur'_U_[R|S]_data.csv')
那么
re.search(mypattern, string)
这里有一个很好的regex创建网站-https://regex101.com/#python
我喜欢先编译regex语句。然后我做任何我想做的匹配/搜索。你知道吗
那么
这里有一个很好的regex创建网站-https://regex101.com/#python
相关问题 更多 >
编程相关推荐