How split the string based on HTML Tags

Hi,

i wanted to split the string based on HTML Tags
Example:
“<“p class=MsoNormal”>” hai team"<“b”>“Name”<“/b”>"
Results:
arr[0]=“<“p class=MsoNormal”>”
arr[1]=hai team
arr[2]=“<“b”>“Name”<”/b">"

can anyone help me on this issue

1 Like

use this regular expression code
System.Text.RegularExpressions.Regex.Split(InputStringVariable,“\<.+\>”)

1 Like

@Himanshu.joshi

no it not working it will returns empty string only any other suggestion

1 Like

Hi @amaresan,

Please assign MathCollection matc= System.Text.RegularExpressions.Regex.Matches(your_string,"(<""\w{1,2}"">[\s\w""]+<""\/\w{1,2}"">"")|(""[\w\s]+"")|(<.*?>)")

The output will be a mathcollection and you can obtain the values by matc.Item(0).Value, matc.Item(1).Value,matc.Item(2).Value etc. I hope your input contains quotes(") and you want to include it in the result too.

Warm regards,
Nimin

1 Like