How would I modify the following javascript regexp so that it matches all of the proceeding patterns?
/(\d\d).+?(\d\d)/
2 of 5
2.5 of 5.6
2.3 of 10
100.4 of 1000
1000.4 of 10000.3
Try this:
/(\d+(?:\.\d+)?).+?(\d+(?:\.\d+)?)/
This will match one or more decimals followed by an optional decimal point and one or more decimals, captured in group 1, followed by one or more of any character, non-greedily, followed by one or more decimals followed by an optional decimal point and one or more decimals, captured in group 2.
Also, if you want to prevent any other characters before or after the matched string, you may need to add a start (^) and end ($) anchor:
/^(\d+(?:\.\d+)?).+?(\d+(?:\.\d+)?)$/
?: purpose?