Find and Replace in Flash ActionScript

Bummed out about the lack of regexp in ActionScript 2.0?

Well, at least you can copy and paste this
"find and replace" function into your code:

// EXAMPLE USAGE:
var a = "Hello World!  The World is great!";
a = findAndReplace(a, "World", "Bob");
trace(a);
// a is now: Hello Bob!  The Bob is great!


All Articles:
  • Java meets Flash (server/client)
  • Freedom of Position (dhtml)
  • Freedom of Position II: Date Picker (dhtml)
  • Video Poker Obsession (optimization)
  • Tag, You're It! Chunk, the All-Purpose Template Engine (java)
  • Look, Ma! Real Scroll Bars! (flash 5)
  • Perl, curl, and HTTPS Post for XML