regex - Replace < and > symbols with < and > symbols in HTML String -
i want regular expression replace < , > symbols < , > in html text , make valid xml.
example string:
<html><body><p style="margin:0px">his <span style="color: rgb(237, 23, 23);">career </span>spanned development of cinema, <span style="font-weight: 700;">silent film</span>, through experiments in <span style="text-transform: uppercase;">technicolor </span>to filmmaking in 21st century.</p><p>his career spanned development of cinema, silent film, through experiments in technicolor filmmaking in 21st century.<this sample></p></body></html>
result:
<html><body><p style="margin:0px">his <span style="color: rgb(237, 23, 23);">career </span>spanned development of cinema, <span style="font-weight: 700;">silent film</span>, through experiments in <span style="text-transform: uppercase;">technicolor </span>to filmmaking in 21st century.</p><p>his career spanned development of cinema, silent film, through experiments in technicolor filmmaking in 21st century.<this sample></p></body></html>
thanks
iyyappan s
that should it:
private function replacetags(string:string):string { string = string.replace(/</gi, "<"); string = string.replace(/>/gi, ">"); return string; } trace("replaced string: " + replacetags("string < >"));
another option wrap text cdata in xml
Comments
Post a Comment