Reputation: 2520
8:9 DAR4:3], 23.98 fps
8:9 DAR4:3], 29.97 fps
8:9 DAR4:3], 25 fps
I've got these 3 possible strings, and I'm looking for an expression that will extract the numbers which occur between the first comma in this line, and the " fps".
either 23.98, 29.97, 25
How best to attack this? Looking behind to whatever digits and dots [\d.] fall before " fps" seems the most logical way but I've never done one of these.
An example, please?
I have this already,
\d{2}\.\d{2}|25
but I'm afraid the "25" could pick up false positives from somewhere later in the text.
Upvotes: 0
Views: 140
Reputation: 39542
(?<=, )[0-9]+(\.[0-9]+)?(?= fps)
should work fine and will only match your numbers.
Upvotes: 1
Reputation: 2363
,\s*(\d+\.?\d*)\s*fps$
Maybe this will work?
,
indicates the the comma
\s*
indicates zero or more spaces.
(\d+\.?\d*)
captures decimal values in a capture group
\s*
indicates zero or more spaces.
fps$
checks to see if fps is at the end of the line.
Upvotes: 2