[Help] How do I use RegEx matches in tokens? E.g. %ICUDateTime%\1%

Hello there,

I want to use a matches result of a regular expression in a token, but I can't get it to work as intended. I checked the wiki pages for Search and Replace and ICUDateTime as well as the forum, but didn't find what I needed to identify the problem.

Any help or advice would be much appreciated!

Here's the macro:


Text - process date tokens.kmmacros (2.7 KB)

My goal is to select some text in any app, and let the macro replace all occurrences of, say, %MM-yyyy%, with 09-2023.

Thank you in advance!

Hi xurc,

Via the wiki and Peter, you cannot use variables or tokens directly within the %ICUDateTime% token.

As a workaround, you can dynamically build the token strings, and then separately use the Filter action to process the new tokens.

Here is a sample macro. As you modify it, beware the tedious percent character placement.

Text - process date tokens copy.kmmacros (4.1 KB)

2 Likes

Thank you for your kind help, Vito! I found the relevant part on the wiki page too now that you point it out:

The text-only parameters must be plain text, and be a valid choice for that parameter.

I didn’t realize the “Filter” Action can be configured to process tokens, sweet!

2 Likes