regex - Javascript regexp search with capture -
how capture 2 integers following string 2 different variables using regexp javascript search?
"10 of 25"
your regex statement going specific strings, answer might specific whatever actual use-case is. put decimals in capturing groups. .+? in front of mean "match lazily until find 2 decimals". --so if there change you'll have 2 decimals shouldn't captured you'd want add checks such positive lookahead/lookbehind quotes, etc.
.+?(\d\d).+?(\d\d).+?
simply refer each capture group $1, $2, etc.
use ?: in group make non-capturing, fwiw.
Comments
Post a Comment