Reputation: 2061
I am using python's re
module to match sequential string in text, for example:
s = 'habcabcabcj'
, I try the following code:
import re
re.findall(r'(abc)+', s)
And the result is: ["abc"]
If I want the match result to be ["abcabcabc"]
, how can I do this?
Upvotes: 1
Views: 125
Reputation:
Use a non-capturing group (?:...)
:
>>> import re
>>> s = 'habcabcabcj'
>>> re.findall(r'(?:abc)+', s)
['abcabcabc']
>>>
Upvotes: 4