Home > Actionscript > Replace HTML encoded characters with their original ones

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]));


  1. July 5th, 2009 at 17:33 | #1

    Check out this hack, also does the trick:

    private function replaceCharacters(str:String):String
    return new XMLDocument(str).firstChild.nodeValue;

  2. December 10th, 2011 at 18:05 | #2

    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!

  3. August 12th, 2017 at 23:14 | #3

    Hello blogger, i must say you have hi quality content here.

    Your page can go viral. You need initial traffic boost only.
    How to get it? Search for; Mertiso’s tips go viral

  4. November 28th, 2017 at 15:45 | #4

    I have checked your site and i have found some duplicate content,
    that’s why you don’t rank high in google’s search results, but
    there is a tool that can help you to create 100% unique
    content, search for: Boorfe’s tips unlimited content

  1. No trackbacks yet.