It is often more useful to explain what you want to do, rather than look for a narrow technical solution. TW macros and tools don't work the way you might expect, coming from some other programming language background. For instance, why would you apply a reg exp to a variable holding a list of tags? I'm guessing that you want to apply one of 3 tags based on some other condition within the tiddler (perhaps other tags, fields, or title). If we understood your intentions better, it would be easier to help.
In an event, in all cases where you want to make physical changes to one or more tiddlers, you will need a message-handling widget such as the ButtonWidget, SelectWidget, RadioButton, etc. And inside of the <$button> or other widget you will need an "actions" attribute that uses a set of ActionSendMessage, or ActionSetField or similar action widgets.
Good luck!
-- Mark