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.

http://regex101.com/r/vn6jo2


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -