Variable (Temporary Tag?) within Action?

I'm using Mp3tag for Mac, but I think it's relevant for other platforms. I have read the relevant documentation.

I have a regular expression that shows up in several format strings within an action that I have defined. Is it possible to define a temporary variable as that value in one of the first items, then use that variable later in the Action? This would remove the need to type the long regular expression repeatedly (and, of course, reduce the odds of mistyping it).

For example, I use the expression
$if2(%ALBUMARTISTSORT%,%ALBUMARTIST%)
to set _DIRECTORY

I would like to use that value twice, to make a parent directory with the capitalized first letter of the result of that regex. (Why? Because Finder is choking on massive folder listings, like that for my artists folder.)

So I would like to be able to define a temporary tag FOO to hold the result of that expression, so I could use
$left($caps3(%FOO%),1)/%FOO%/
to place, say, an album by U2 in the folder U/U2/

Possible? Is it built in? I figured that I'd ask first, to avoid the possibility of breaking things.

I am not quite sure if I understand the problem correctly.
I assume that you want to save the result of

somewhere as you need that string for other purposes.

You could write the value to any tag field you like, even a user-defined one like e.g. MY_ARTIST and use the contents of that field in other actions and action groups until you remove the field MY_ARTIST again.

OK, to be sure I understand:

Can the tag name (in your example, MY_ARTIST) be any arbitrary string?
Would I think simply reference it as %MY_ARTIST% ?
Would it remain associated with the track after the action ends?

Yes - it should not be the same as a reserved name for a standard tag field or a file property.

Exactly.

The field is saved like any other (user-defined) field in the file - and stays there until the user (you?) explicitly deletes it.
It is possible to remove a field (also this user-defined one) with an action that is part of the action group.