Tuesday, 27 September 2011

Replace all html codes into its equavalent angle brackets in JavaScript


function RestoreAngleBracketsFromHtmlCode(strInput)
{
   strInput = strInput.replace(new RegExp(['&lt;'],"g"), "<");
   strInput = strInput.replace(new RegExp(['&gt;'],"g"), ">");
  
   return strInput;  
}

alert(RestoreAngleBracketsFromHtmlCode("&lt;Ravi&gt;"));

Output:
<Ravi>

No comments:

Post a Comment