It is a type of meta-processing.
"Telling" is where the effort is.
Example of doing expl3 replace by escaping out of minted's verbatim environment and applying a replace-command:

Using unique identifiers, and going directly to (unicode) math glyphs, makes maintenance easier and avoids minted's math-mode glitching.
But probably easier just to type x ∈ ℜ in a unicode-math space in the first place, without needing to use a lookup command at all, and switching fonts automatically, maybe in an environment-in-an-environment (somehow). Fancyvrb's verbatim environment keeps getting in the way.
MWE
\documentclass{article}
\usepackage{xparse}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\setsansfont{Noto Sans}
\setmonofont{Noto Sans Mono}
\newfontface\mymfont{XITS Math}
\DeclareTextFontCommand{\textmymath}{\mymfont}
\usepackage{minted}
\ExplSyntaxOn
%=====================================
\tl_new:N \l_mytrans_tl
\NewDocumentCommand { \translit } { m } {%
\tl_set:Nn \l_mytrans_tl { #1 }
\dotranslit
\tl_use:N \l_mytrans_tl
}
%---- Environments
\NewDocumentEnvironment{translite}{ +b }
{
\tl_set:Nn \l_mytrans_tl { #1 }
\dotranslit
\tl_use:N \l_mytrans_tl
}
{ }
%-----
\newcommand\dotranslit{%
\tl_replace_all:Nnn \l_mytrans_tl { mlambda } { $\lambda$ }
\tl_replace_all:Nnn \l_mytrans_tl { xlambda } { \textmymath{} } % U+1D706 MATHEMATICAL ITALIC SMALL LAMDA
\tl_replace_all:Nnn \l_mytrans_tl { xreal } {\textmymath{ℜ} } % U+211C BLACK-LETTER CAPITAL R : real part
\tl_replace_all:Nnn \l_mytrans_tl { xelementof } { \textmymath{∈} } % U+2208 ELEMENT OF
\tl_replace_all:Nnn \l_mytrans_tl { xmapsto } { \textmymath{↦} } % U+21A6 RIGHTWARDS ARROW FROM BAR : z notation maplet
}
\ExplSyntaxOff
\begin{document}
xlambda $\mapsto$ \translit{xlambda}
\begin{minted}[linenos=true,escapeinside=||]{tex}
% This is a TeX comment but is not disregarded because it's inside
%| {\rmfamily ffi ffl >> -- --- } | font ligatures yes, TeX ligatures no.
| {\rmfamily xlambda = \translit{xlambda} } |
| {\translit{x xmapsto y xelementof xreal}}|
\documentclass{article}
\usepackage{minted}
\begin{document}
Dont use $$ in \LaTeXe! % It's weird!
\end{document}
\end{minted}
\end{document}
->) with other sequences of characters (eg\to). – fakedrake Oct 19 '21 at 01:49replaceorregexcan do a substitution, andmintedwhen doing the verbatim environment can escape to latex code, but (manual, p24): "Note that when math is used inside escapes, any active characters beyond those that are normally active in verbatim can cause problems." and then links to: https://tex.stackexchange.com/questions/223876/fancyvrb-error-with-math-escapes-and-prime Unrelated: Interestingly, a%in atexminted typesets the line as latex, but you have to switch to\rmfamilysince monospace doesn't have ligatures. – Cicada Oct 19 '21 at 09:41