New Find and Replace Function for String

So, doing string parsing for this project, no big deal and suddenly weird stuff starts happening. It seems that indexOf is detecting “th_” in the word “stunt”. Ok, most programmers are cool with that… I can work with that.

But suddenly, String.split start’s doing some whacked things…

5 Replies to “New Find and Replace Function for String”

  1. I think I ran into this problem this last week. I couldn’t understand why my simple split was failing. I broke it down to just doing a split (no other code) and it worked fine in the Flash IDE. When testing with my application (desktop stuff) it would fail.

    Turned out my desktop app was using Flash Player 7r14 and I had updated my system (browsers and Flash IDE) to 7r19. 7r19 fixes the issue.

    Luckily we have control over the Flash Player that ships with our product, and the end users will have no choice but to use the version in the software. However, for web development, this bites, big time.

    All of the functions to replace the MM split function that I’ve seen use substring, which is deprecated in MX04. Although they might be faster, if MX0… (05/06 whatever) doesn’t accept substring, then the functions have a rather limited lifespan. The thing is substring is supposed to be replaced by substr, but I tried substituting substr into the replacement split functions (correcting for the 0-based index) and they behaved the same as the MM split. Strange… so was substr the problem?


  2. I got a simple fix for this. Actually I got this from the Flash Actionscript Bible MX. It should work for MX 2004 as well (in theory, but haven’t tried it personally). The Actionscript Bible came with a custom .as class that was created by a fellow named Pavils Jurjans. I have been using it to do search and replace functions in a string. It is very easy to install and use. It is called the RegExp class (says it works with Flash 5 and MX, but it should work for MX2004 as well). You can get it here for free: <a href=””></a&gt;

    Once installed, it will appear in your list of String actionscript functions. Examples on how to use it are also at that site. I made an interactive sample for ya here though (with actionscript): <a href=””></a&gt;

Comments are closed.