i want a regex to find out specific html tag details.
i tried bellow 2 regex :
<\s*tag[^>]*>(.*?)<\s*/\s*tag>
<tag[^<>]*>.+?<\/tag>
bellow are the 2 test cases for 1st regex :
in 1st example i am getting correct result but in the example 2 i am getting wrong result. where in both the cases in-puts are almost same.
1st case : all are as individual string and 2nd case : as a single string.
===================================
Example 1 Input
===================================
<tagX>AAA</tagX>
<tag>GGG</tag>
<tag id="tag896">HHH</tag>
<tagY>III</tagY>
<tag id="tag017">JJJ</tag>
<tag>KKK</tag>
===================================
Output 1 // Correct
===================================
<tag>GGG</tag>
GGG
<tag id="tag896">HHH</tag>
HHH
<tag id="tag017">JJJ</tag>
JJJ
<tag>KKK</tag>
KKK
===================================
Example 2 Input (as a single string)
===================================
<tagX>AAA</tagX><tag>GGG</tag><tag id="tag896">HHH</tag><tagY>III</tagY><tag id="tag017">JJJ</tag><tag>KKK</tag>
===================================
Output 2 // Wrong
===================================
<tagX>AAA</tagX><tag>GGG</tag>
AAA</tagX><tag>GGG
<tag id="tag896">HHH</tag>
HHH
<tagY>III</tagY><tag id="tag017">JJJ</tag>
III</tagY><tag id="tag017">JJJ
<tag>KKK</tag>
KKK
here exactly i want the details of (tag) but in 2nd case its fetching (tag) + (tagX) + (tagY) details.
my input is similar to 2nd input...
its lil urgent... can i get a solution for this.
thanks...