I'm trying to parse out prices but ignore two patterns that are also prices. One of the exclusions is the total price which is at the end which I am using lookahead to ignore. The second exclusion is if there's a variation of the letter Q before a price, for example Q10.00 or Q AWSMSN11.32 but I want to include if there's a three letter alpha that happens to end in Q such as YMQ234.03.
I've added a negative lookbehind but can't seem to get what I want.
This is the pattern I've tried: (?<![Q\d]) ?M?(\d+\.\d{2})(?=.*\d+\.\d{2}END)
test strings
ABC WS YMQ234.03WS TOY234.03USD468.06END
FUR BB LAB Q10.00 199.00USD209.00END
YAS DG TYY Q AWSMSN11.32 2503.08LD VET Q JKLOLE11.32 2503.08USD5028.80END
PPP VP LAP Q10.00 M342.41EE SFD Q10.00 282.24USD644.65END
Expected output
+---------------------------------------------------------------------------+---------+---------+
| 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 |
+---------------------------------------------------------------------------+---------+---------+