How to match only those numbers which have an even number of `%`s preceding them?
I want to catch numbers appearing anywhere in a string, and replace them with "(.+)". But I want to catch only those numbers which have an even number of % s preceding them. No worries if any surrounding chars get caught up: we can use capture groups to filter out the numbers. I'm unable to come up with an ECMAscript regular expression. Here is the playground: abcd %1 %%2 %%%3 %%%%4 efgh abcd%12%%34%%%666%%%%11efgh A successful catch will behave like this: Things I have tried: If you have realised, the third attempt is almost working. The only problems are in the second line of playground.