Action "Set Variable to Text" ignores word boundary "\b"

I'm using a Variable as a RegEx search string to return a value from a look-up list saved as another variable. I would like the search term to include the (literal) characters" \b" (i.e.: "{backslash}b") to designate a word boundary. The Action "Set Variable to Text" seems to ignore "\b", as shown below. Help?

Here is the action, showing a result:

Text fields (that are not regular expression fields), process backslashed characters \a,\b,\e,\f,\t,\r,\n (bell,backspace,escape,form feed,tab,return,line feed).

So if you want to use a backslash in these fields, you need to double the backslash.

1 Like

Got it. Thank you.

Sent from my mobile.

Sorry for bumping up an older thread,

but I guess it is still better then make a new one with the same content.

Wouldn’t it be possible to make a separate kind of text fields, which is not affected by any evaluations? Or probably to make a switch “do not process characters” in the text block?
I use KM for text snippets and it is annoying with the code and latex snippets. There is no way to fix this problem with, let us say, a regex-replacement inside the macro, following the text block, since all the affected characters with backslash just disappear for everything inside KM.

Basically, it runs down to running a regex with the text in other editor which replaces backslash with double backslash for these letters, thus preparing it for usage in KM.

I will note does the request for an option to the Set Variable to Text action to disable \ processing. I doubt I would add it as an option to every text field, but at least that would give you a way to get the text into Keyboard Maestro.

Peter, that could be very handy.
Several times I have needed to use the same RegEx pattern in several different Actions. So I would be very nice store it in a variable, provided that the RegEx fields accept a variable (like on Search Clipboard).

Peter, that could be very handy.

+1. I have created created nearly-impossible-to-parse RegEx's that input RegEx's and output text that can be used as a variable. The process is, imho, inherently silly (perhaps a bit like bicycling backwards while playing the flute), error-prone, and tedious to trouble-shoot.

1 Like

Done for the next (after 7.0.3) version. Added an option to the Set Variable to Text action to disable backslash or backslash and text tokens processing.

1 Like

Thanks! :slight_smile: