regex – I want to match the “$$” at the beginning and the “$$” at the end separately, and replace them with “`$$” and “$$`” respectively – TeX

Here are some samples:

If the object moves at a constant speed over a distance of $2L$ in a straight line within time $2t$, then the time elapsed for the object is:

$$
\tau_1 = 2t \sqrt{1 - \left(\frac{L}{ct}\right)^2}
$$

I have tried writing a regular expression but failed:

Formulas that match a single $:

(?

I have been confused for a long time and don’t know how to change it. I can’t find the corresponding answer on the Internet. I hope to get your help.

Search in Google and find the post in Stack Overflow

Read more here: Source link