Replace HTML encoded characters with their original ones
February 12th, 2009
Just a simple regular expression to replace all HTML encoded characters with their original ones.
var testString:String = "This is a test with a – character and a ’"; testString = testString.replace(/&#([0-9]+);/g, replaceCharacters); private function replaceCharacters(...args):String { return String.fromCharCode(parseInt(args[1])); }
Check out this hack, also does the trick:
private function replaceCharacters(str:String):String
{
return new XMLDocument(str).firstChild.nodeValue;
}
That’s truly exciting. This introduced i am two or three thoughts and then I’ll be posting these products for my web-site finally. I’m just book-marking your blog and also Soon we will be back. Thank you!