I need a regular Expression to get a string in between <ul> and </ul> tag...
But the thing is if there is one "<ul></ul>" tag inside the <ul> tag then regex stops with the inner tag...But i need the entire string between the outer two tags...
Can anyone help me?
Asked
Active
Viewed 51 times
0
Vignesh Murugan
- 555
- 5
- 18
-
2Don't try to parse arbitrarily nested HTML using regex. [It won't work](http://stackoverflow.com/a/1732454/362634). Use a proper HTML parser instead. – Marius Schulz Nov 14 '13 at 08:35
2 Answers
0
Try this regex
String text = "<ul>My list</ul>";
String text1 = text.replaceAll("</?ul>", "");
^
? says / one time or none at all
So it will take out <ul> and </ul>
This is java language by the way. The regex may work in different languages
Paul Samsotha
- 197,959
- 33
- 457
- 689
-1
it will pick everything between from the first <ul> to the last </ul>.
<ul>(.*)</ul>
Sabuj Hassan
- 36,940
- 12
- 73
- 83