0

I'm trying to write a python script using regex that will take a string such as this one:

string = "C:66:66:0:0%:1E0 C:18:18:0:0%:1E0 C:26:26:0:0%:1E0 C:95:95:0:0%:1E0 Y:106:104:2:1.89%:2.4882E-1

and break it up into chunks such as this

C:66:66:0:0%:1E0

The code I have right now is:

res = re.findall("\w+:\d+:\d+:\d+:\d+%:\w+", string)

but the output leaves out everything following the "Y" due to the decimals

['C:66:66:0:0%:1E0', 'C:18:18:0:0%:1E0', 'C:26:26:0:0%:1E0', 'C:95:95:0:0%:1E0']

Does someone know how the regex can be modified so that it includes optional decimals in the string? Thank you!

bleep
  • 13
  • 2

0 Answers0