I have a string
CO12dadaCO2dafdCO345daaf
I need to retrieve all instances of CO followed by numbers /CO(\d*)([\s\S]*)/
, until the next CO appears.
In this scenario, I expect the following output:
['CO12dada', 'CO2dafd', 'CO345daaf']
The regex pattern I attempted also captures all subsequent CO occurrences at once, rendering it ineffective.
While str.search
helps locate the index of the first match with a regex, I require the indexes for every instance found.