How to Use Variables in Regular Expression Searches?

Hello! Is it possible to use variables in regex searches, i.e. something like:

%ThisAddress%([^\s]+)

Thanks so much!

Yep. Pretty much just like you stated.
One thing to keep in mind is to account for the KM Variable containing any RegEx meta characters.
There is a procedure to "escape" these meta characters.
See

The weird problem that I'm having is that this works:

([^\s]+)%Variable2%

...but this does not work...

%Variable1%([^\s]+)%Variable2%

And I've confirmed that the regex is formed properly.

I have tested this. It is working on my side. It can extract the string
Can you try to see if my macro work on your mac ?

[EXP] Test macro.kmmacros (2.1 KB)

Shouldn't your Local_name match should have been equal to extraction ?

yes, it display extraction

Hmmm. In my case, the regex is much more complex, but it matches if I literally include the %Local_v1% content, but does NOT match if I include the variable representation.

Or maybe you want to be specific on the input regex that you test and what output you expecting as I not too clear on this "%Local_v1% content, but does NOT match if I include the variable representation."

Here's the specific regex:

<b>To</b>[^>]+>[^>]+[^>]+>[^>]+[^>]+>[^>]+>%ThisAddress%</span>[^\$]+\$[^\s]+\s\/\s%ThisReceivedCoin%\"\>([^\s]+)

This regex fails to match the contents of the variable being searched. If I remove %ThisAddress% from the regex, and type in the actual address in the regex, then it does match the searched variable content.

(And I've confirmed that %ThisAddress% contacts the correct data.)

I can confirm along with @macdevign_mac that using a KM variable works in a KM RegEx.
For us to be helpful, you need to provide your complete use case, with ALL data.
The best thing would be to upload a Macro that contains all data needed to test your Regex.

Thanks. I'll try to reproduce it, and create a macro to post here. Thanks again so much for trying to help out. I really appreciate it!