The expression
"abcb".replace(/(?:a)b/, 'x')
returns "xcb". What I want it return is "axcb"; that is, the "a" is not captured.
Is this possible in a single regex?
You can make it capturing:
"abcd".replace(/(a)b/, '$1x')
//=> axcd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With