I am trying to learn regular expressions by writing something akin to latex2html in Python. But I am having a hard time figuring out how to match latex equations — things of the form $ … $ where … can be any expression in LaTeX, while allowing for escape sequences at the same time.
In other words, the problem case is $\$$. I want the regular expression to match on $\$$, rather than just $\$.
You can use negative lookbehind to make sure you don’t match \$. something like:
E.g.
will find two matches:
$x= \$12$and$x=12$