Conditional addition of an underscore

In the following macro I'm inputting a type of musical glyph into Sibelius (a music notation application) as a regular font.

The trick with the font is that it needs an underscore before each digit to display correctly.
This means that if I input '4' as the value, it shows correctly, because it is formatted as ({_4})

However, if I input '12', this macro exports ({_12}), when it should be ({_1_2}) to display correctly.

Is there a way to have KM input the extra underscore, if my input is two digits?


If you add the following Search/Replace: Regex just after the input prompt, it will add an underscore in front of each digit:


Your insert would then change to be just MultiRest, as the underscores are baked in. If you need the original input unaltered, just set the Search/Replace to save to a new variable, and use that variable in the Insert by Typing action.


Thanks, Rob! Had to tinker with the delays to get it working but it does now :slight_smile:

Glad it's working!