I am trying to extract the TPS number from the following strings using Java – the strings will be read from a file and so the strings can appear in any order (not known in advance), e.g. I wont know which of the strings I am dealing with – it could be either of these two:
Testing performance TPS.. ok. (795 TPS recorded for run)
Testing performance TPS.. warning: TPS seems low - it was 10 TPS and I expected to achieve over 50
E.g. for the first string I would want the number 795, and for the second string I would want the number 10.
Does anyone know how to do this with regex or similar using Java?
Many thanks
If you’re always looking for an integer followed by the string “TPS” you can do
But you’d better be sure it will always be in this format – it would be better to modify the output format, if that’s possible.