re: A regex cheatsheet for all those regex haters (and lovers) 👀 VIEW POST

FULL DISCUSSION
 

I would add "how to reverse the sides of an equation" to this list. There are a few other handy tricks for coders, but this is the most common I can think of right now

 

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")

code of conduct - report abuse