regex - How to escape the second capture group the first time in javascript regular expression -
This would be useful if someone could recommend a way to avoid another capture group for the first time. The expression is as follows:
(\ d) (? = (\ D {3}) (\ d {2}) + (?! \ D))
I want to leave the second capture group (\ d {2})
for the first time and evaluate this group (\ d {3})
just one time.
This idea is to find the position of the number. Now, 1000000000 as of 1,00,00,00000 is being evaluated, I want it to be 1,00,00,00,000.
It looks like this should work for you:
"1000000000" .replace (/ \ d (? = (?: \ D {2}) * \ d {3} (?! \ D)) / g, "$
I removed all unnecessary capturing groups, and instead of capturing \ d, use
. $ & amp;
to reference the main match
Comments
Post a Comment