I have a string
CO12dadaCO2dafdCO345daaf
I want to extract all occurences of CO followed by some digits /CO(\d*)([\s\S]*)/
, up to another CO.
In this case I want to get the output:
['CO12dada', 'CO2dafd', 'CO345daaf']
The above regex I tried also matches the rest of the CO's at once so it doesn't work.
I could get the index of a regex for the first match using str.search
, but I need the indexes of a regex for all occurrences.