DEV Community


Discussion on: A regex cheatsheet for all those regex haters (and lovers) 👀

sesc profile image
Sebastian Schleussner • Edited

Yes. If I understand you correctly, that would at the same time be a good example case for another detail I was about to suggest: Match-parenthesis references in the replacement.
Something like:
"a = b + c".replace(/^(.+?) *= *(.+)$/, "$2 = $1")