This is a bit of a guess since I’m away from my Mac but try this: in your Set Variable action click the gear icon and choose “no processing” option (it’s probably not called that exactly, but I hope you can guess the right one). If that option is not set then KM will try to interpret your regex string and change it possibly.
BTW, your regex should have the double backslash in it - A\\ B