Use variable token to pass REGEX - Backslash issue

I want to use variable token to pass a REGEX into action.

My current stage is like the above picture.

My target is
A B
My REGEX is
A B

I test but find if there is \ in the string, this macro doesn't work.

My target is
A\ B
My REGEX is
A\ B
A\\ B

I use A\ B, fail. Then I use \\ to escape \, fail too.
So I am asking for help here. I cannot find what's wrong.

Question - use variable token to pass REGEX.kmmacros (3.5 KB)

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

2 Likes

Process nothing works.

It's the first time for me to know these options in gear menu.

Many thanks!

2 Likes