Flipping Assignments With Regexs
Don’t you hate those forms you sometimes have to build where you load values for a ton of controls and then have to basically reverse the statements later on to save the values? I found an easy way to flip the statements on the equals sign using regular expressions in Notepad++. Neato!
Essentially we’re creating two groups. (.+) is the first group [=] marks the end and (.+) is the second with ; excluded.
From here we can simply say \2 = \1; is our replacement.
This particular example isn’t quite as clean because I was doing a bit tweaking to the values but it still saves me a ton of time only having to trim up a few lines rather than rewriting them or doing lots of copy / pasting.