How to parse environment variables and globals from a field I want the ability to parse environment variables such as {siteName} and globals from channel fields, for example a rich text field.

I have been using {{ include(template_from_string(entry.fieldName)|raw) }}, but this is not suitable because it gives authors the full power of twig.
Brandon Kelly pointed out that using the replace filter can work {{ entry.fieldName|replace('{siteName}', siteName)|raw }}

Using a macro I can make this manageable.

I would like the ability to use globals too, what is the best way to have all globals being options to replace or using another method?

Would having 20 possible variable options to replace cause any issues, I would be calling this 3-4 times in a template.
You could enable your client to use Reference Tags by adding the parseRefs filter.

{% set str = '&lt;p&gt;Since {globalset:42:yearEstablished}&lt;/p&gt;' %}
{{ str|parseRefs|raw }}


But this would enable them to access field values of (almost) any element (entries, assets, tags, ..), not just from global sets.
And they would also have to remember the global set's ID.

So your current replace filter solution is a good approach in my opinion. You can pass multiple replacements pairs like so
(and no, you won't notice if there's 1 or 100 of them):

{% set str = '&lt;p&gt;Since {yearEstablished}&lt;/p&gt;' %}
{% set replacements = {
    '{yearEstablished}': companyInfo.yearEstablished,
    '{siteName}': siteName,
} %}
{{ str|replace(replacements)|raw }}


You could also consider building that replacements array programatically.