This macro enhances the tagging functionality of Evernote's native macOS client by providing a way to search for tags in an "unanchored" way, that is, if I have a tag "gotomuseum", I can find this tag when searching for "museum", whereas the native tag autocomplete would only find the tag, if I typed at least "gotom". This is helpful, when having lots of tags in a deeply nested tag hierarchy.
This is just a way to normalize the strings, since I had Problems when first trying to parse my list of tags as is. YMMV and maybe it's not needed in your case.
As to why I used perl here: I just tried to find a mostly platform independent way to normalize the strings. This is mostly a googled command slightly adapted to our use case here (I don't know how to use perl either).
We have a long list of tags of the form:
tag foo, tag bar, tag foobar, ...
We want to do something with every actual tag, so we use the slightly initmidating looking regular expression.
Got it. The Debuggex website is a new one for me. Looks good.
Btw, I think you may be able to avoid getting the tag word into your variable if you use the following AppleScript. As it seems to me that you are getting rid of the "tag " portion using a regex. (Although I suspect you already know this.)
tell application "Evernote"
set theTags to name of every tag
return theTags
end tell