Adding a wildcard to a script

Hi there!

Apologies as this will no doubt be very simple to do, but struggling with the syntax to use a wildcard in the 'on value' script field.

I essentially want to write something like

if (value == "macro_*") {

for "macro 1", "macro 2" etc, but using the wildcard in this way does not work. Tried various permutations but having no joy so far!

Any help greatly appreciated!

You can't use wildcards like that in javascript, you'll want something like

if (typeof value == 'string' && value.match(/^macro_/)) {
}

Thanks again Jean-emmanuel, top support as always; thanks to the syntax you suggested, I found this worked perfectly for my needs:

if (value.match(/Macro/)) {

Back to working on template now! :slightly_smiling_face:

Just in case, the leading ^ is important, it indicates you want the pattern to match the beginning of the string.

1 Like