You can use
/(?<=Q)(?:\d+(?![.\d])|\d+\.\d+(?![.\d]))/gm
demo
(?<=Q)
is a positive lookbehind. It requires the match to be immediately preceded by "Q"
, but "Q"
is not part of the match.
I've made assumptions about which strings can be matched. Those are reflected at the demo.
The regular expression can be written in free-spacing mode to make it self-documenting:
/
(?<=Q) # match 'Q' in a positive lookbehind
(?: # begin non-capture group
\d+ # match representation of an integer (1+ digits)
(?![.\d]) # do not match a period or digit (negative lookahead)
| # or
\d+\.\d+ # match representation of a float
(?![.\d]) # do not match a period or digit (negative lookahead)
) # end non-capture group
/gmx # global, multiline and free-spacing regex definition modes