a='aa'
b='aaa'
c=re.findall(a,b)
print(c)# 输出结果为['aa'],只有一处匹配位置
但是我觉得应该有两处匹配,输出结果应为['aa','aa'] 怎样解决这个问题啊?
a='aa'
b='aaa'
c=re.findall(a,b)
print(c)# 输出结果为['aa'],只有一处匹配位置
但是我觉得应该有两处匹配,输出结果应为['aa','aa'] 怎样解决这个问题啊?
文档里面写了的,如下
?re.findall(pattern, string, flags=0)
Return all non-overlapping matches of pattern in string, as a list of strings. The string is scanned left-to-right, and matches are returned in the order found. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.
是非重叠匹配
2 回答5k 阅读✓ 已解决
2 回答1k 阅读✓ 已解决
4 回答893 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
1 回答1.6k 阅读✓ 已解决
1 回答1.2k 阅读✓ 已解决
正则好像不太好弄。可以用代码实现。
其实这个跟leetcode这个题比较像:https://leetcode-cn.com/probl...
简单点就这么写。