Scan through string looking for a location where the regular expression pattern produces a match, and return a corresponding match object. Return Noneif no position in the string matches the pattern; note that this is different from finding a zero-length match at some point in the string.
使用^{} ,而不是
re.match()
;后者只匹配字符串开头的:演示:
您需要使用
re.search()
而不是re.match()
。第一个是查找字符串中任何位置的模式,另一个是查找模式是否可以准确地应用于字符串。你知道吗From the documentation:
示例:
相关问题 更多 >
编程相关推荐