# Why does this code work intermittently

**URL:** <https://forum.kirupa.com/t/why-does-this-code-work-intermittently/328929>\
**Category:** flash\
**Created:** [July 3, 2012, 5:18pm UTC](https://forum.kirupa.com/t/why-does-this-code-work-intermittently/328929 "2012-07-03T17:18:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![m2244](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@m2244](https://forum.kirupa.com/u/m2244)\
**Post date:** [July 3, 2012, 5:18pm UTC](https://forum.kirupa.com/t/why-does-this-code-work-intermittently/328929/1 "2012-07-03T17:18:21Z")

</div>

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]

```auto

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 = /&lsquo;/;
 loadedHTMLFile = loadedHTMLFile.replace(regex2,'&#8216;');
 loadedHTMLFile = loadedHTMLFile.replace(/\s{1,}(.*?)/g, "$1 ");

```
