regex_replace

regex_replace is similar to the replace filter, except the first paramter should be a regular expression to match, rather than a plain string. You should not surround the regular expression with forward slashes. Optionally, you may also include the modifier flags as a third parameter, and a maximum number of matches to return as the fourth parameter.

{# Standardize the company's name in text #}
{{ entry_text|regex_replace('nmc|new media( campaigns)?','New Media Campaigns','i') }}

For security reasons, you cannot use the "e" (evaluate) modifier.