I'm using Python 3's re.findall to find all occurrences of a substring within a string:
import re
full_string = 'ABCDCDC'
sub_pattern = 'CDC'
re.findall(sub_pattern, full_string)
re.findall
only finds ['CDC']
, however, the pattern CDC
occurs 2 times in the full string.
Why isn't re.findall
finding all occurrences of CDC
here?
What's needed so that re
correctly finds all occurrences?