See: CoreRuleTokenReplacementGeneratorImpl
Note that you can also provide a custom one if needed.
Also regular variables from memory get substituted, you can either check the memory via the devMode dialog option or look in CoreCampaignPlugin.
Thanks! In this case, I'm parsing a returned string that is sometimes randomly selected and replacing found variables that way since the string is being pulled from a different spreadsheet instead of being contained in rules. I already have the parsing/replacement algorithm working, I just need all the variable definitions to check for. I haven't stress tested using every variable yet, but I doubt it will be an issue.
I will implement the custom generator if needed, but as long as I have the hooks to get the entity information for each variable then it shouldn't be necessary- though I haven't looked at it yet. It might give me some pointers on keeping the algorithm efficient. Thanks again for all the help you give to modders.
*EDIT* Oh you know what, I can use the public method to get all the replacement tokens for the script in a map. That will save a lot of time!