Why does this code work intermittently

Hello,

I have a swf that pulls text from an html file. Other people here in the office are accustomed to using html special character codes. Flash seems to have a problem with html special char codes so I have the code below in the swf so I can look for the html codes and convert them to something Flash can use. The problem is, it doesn’t catch all of the instances of the special char codes.

Any ideas?

[COLOR=#FF0000]I found it. It’s been a long week. The ‘g’ was missing.[/COLOR]


var rex:RegExp = /[
]*/gim; 
 loadedHTMLFile = loadedHTMLFile.replace(rex,'');
 loadedHTMLFile = loadedHTMLFile.replace(/\s{1,}(.*?)/g, "$1 ");
 
 var regex1:RegExp = /&rsquo/g;
 loadedHTMLFile = loadedHTMLFile.replace(regex1,'&#8217');
 loadedHTMLFile = loadedHTMLFile.replace(/\s{1,}(.*?)/g, "$1 "); var regex2:RegExp = /‘/;
 loadedHTMLFile = loadedHTMLFile.replace(regex2,'‘');
 loadedHTMLFile = loadedHTMLFile.replace(/\s{1,}(.*?)/g, "$1 ");