fork download
  1. import re
  2.  
  3. s = 'RefBu12CyclesAmpl0.20Freq2.25VR0.0000Dist4cmSilence25000Fs25MHz';
  4.  
  5. values = [ float(x) for x in re.split('[a-zA-Z]', s) if x ]
  6. print(values)
  7.  
  8. names_values = [ (x[0], float(x[1])) for x in re.findall(r'([a-zA-Z]+)(\d+[\.\d+]*)', s) ]
  9. print(names_values)
Success #stdin #stdout 0s 23296KB
stdin
Standard input is empty
stdout
[12.0, 0.2, 2.25, 0.0, 4.0, 25000.0, 25.0]
[('RefBu', 12.0), ('CyclesAmpl', 0.2), ('Freq', 2.25), ('VR', 0.0), ('Dist', 4.0), ('cmSilence', 25000.0), ('Fs', 25.0)]