Replace $x<y$ by $x < y$
问题 I want to search in text for the less than sign < between dollar signs like $x<y$ and replace it by $x < y$ . I am using mathjax and less than sign causes some problems in rendering Mathjax.(See here: http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents). I tried $text = preg_replace("/\$(.*?)(<)(.*?)\$/","/\$$1 < $3\$/",$text) but I am not sure if this is a good solution. I am new to programming:) Thank you for your help. 回答1: I edited my previous answer - now try this: