Replace backslash escape only in old posts after import

I’m aware of rake posts:remap["find","replace"].

In this specific case I guess it would be

rake posts:remap["\\%","\\\\%"]

However, when looking at the code, it seems like regexp is also supported.

So something like

rake posts:remap["(?<=[^\\])\\%","\\\\%","regex"]

should replace all occurrences of \% which are not preceded by another \. But it seems this regexp is then passed along to the database layer which doesn’t support lookbehinds.

It’s tricky. Thanks for any further ideas.