I have a Big string which has multiple mathmls in it. Want to take out all of them in a string array. Using regex to find them. But something missing in the regex so it doesn’t gives any output.
What is the regex for MathMls?
Example string
Find sum of «math xmlns=\”http://www.w3.org/1998/Math/MathML\”»«mroot»«mrow»«mi»#«/mi»«mi»a«/mi»«/mrow»«mn»3«/mn»«/mroot»«mo»=«/mo»«mroot»«mrow»«mi»#«/mi»«mi»b«/mi»«/mrow»«mn»3«/mn»«/mroot»«/math» and «math xmlns=\”http://www.w3.org/1998/Math/MathML\”»«mo»=«/mo»«msup»«mfenced»«mrow»«mi»#«/mi»«mi»b«/mi»«/mrow»«/mfenced»«mfrac»«mn»1«/mn»«mn»3«/mn»«/mfrac»«/msup»«/math»
From this get 2 mathmls
You can’t do that with Java’s regex engine since this is valid input:
i.e.: there can be arbitrary nested tags and Java’s regex engine has no ability to match recursive patterns. You will have to resort to some parser to handle MathML input.
EDIT
In that case, try this pattern:
or as a String literal:
which means: