1) Fix a bug whereby multiple '\'es in the replace part of a search and ...

...replace

string were getting collapsed into a single one.
2) Split flipEscaping into two specialized functions -- one for the regex part,
and one for the replace part.