I'm trying to create an environment, which would find and replace certain patterns in its body and would not conflict with other environment that would possible include it. One of the possible usage scenario may look like this:

```
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
\begin{foo}
a -> b \\ c -> \LaTeX
\end{foo}
\end{gather}
\end{document}

```

Here, my `foo` environment should replace `->` with `\to` (in my real case I have many more patterns). Another possible usage, this time without `gather`:

```
\documentclass{article}
\begin{document}
\begin{foo}
a -> \textbf{\TeX}
\end{foo}
\end{document}

```

How would you do this? (I would prefer to use `\regex_replace_all` from `expl3`, but it's not a requirement.)