I have the following html string that I need to parse for all latex expressions using regular expression.
A latex expression is anything that is delimited by $$ or \$. For example, $$x^2-x+1 = 0$$
and \$x=34\$
are latex expressions in html string below..
<p>$$x^2-x+1 = 0$$</p>
<p>Another example of inline Latex is \$x=34\$.$$x^2-5x+3 = 0$$</p>
What are the roots of following equation: \$x^2 - 2x + 1 = 0\$?<br class="t-last-br" />
My aim is to get all latex expressions in above string. For this I have used these regular expressions. (I have used the online regex tester at [Regex Storm].1
- ((\\$)[\W\w]+(\\$)){1} to get latex expressions delimited by \$
- ((\$\$)[\W\w]+(\$\$)){1} to get latex expressions delimited by $$
Even though I am getting a match with above regular expressions as in screen shots below, but its not matching multiple regular expressions.
Question
What is missing in my above regular expressions that is causing it to not match the multiple latex expressions that are present in the given html string?