fork download
  1. import re
  2.  
  3. regex = r"\b[A-Z ]*Q[A-Z ]*(?<![A-Z][A-Z]Q)\d+\.\d+|(\d+\.\d{2})(?!END)"
  4. strings = [
  5. "ABC WS YMQ234.03WS TOY234.03USD468.06END",
  6. "FUR BB LAB Q10.00 199.00USD209.00END",
  7. "YAS DG TYY Q AWSMSN11.32 2503.08LD VET Q JKLOLE11.32 2503.08USD5028.80END",
  8. "PPP VP LAP Q10.00 M342.41EE SFD Q10.00 282.24USD644.65END"
  9. ]
  10.  
  11. for str in strings:
  12. print('{}: {}'.format(str, [x.group(1) for x in re.finditer(regex, str) if x.group(1)]))
  13.  
  14.  
  15.  
Success #stdin #stdout 0.02s 9528KB
stdin
Standard input is empty
stdout
ABC WS YMQ234.03WS TOY234.03USD468.06END: ['234.03', '234.03']
FUR BB LAB Q10.00 199.00USD209.00END: ['199.00']
YAS DG TYY Q AWSMSN11.32 2503.08LD VET Q JKLOLE11.32 2503.08USD5028.80END: ['2503.08', '2503.08']
PPP VP LAP Q10.00 M342.41EE SFD Q10.00 282.24USD644.65END: ['342.41', '282.24']