Dodona gives you answers

How do I find and replace a string in actionscript 2?

leave a comment »

I use this findReplace function to replace a string in actionscript:

// (from
var findReplace = function(searchStr:String, findStr:String, replaceStr:String) {
   var locationNum:Number = searchStr.indexOf(findStr, 0);
   while (locationNum != -1) {
      var sub1 = searchStr.substr(0, locationNum);
      locationNum += findStr.length;
      var sub2 = searchStr.substr(locationNum, searchStr.length);
      var searchStr = sub1 + replaceStr + sub2;
      var locationNum = searchStr.indexOf(findStr, sub1.length);

Status: tested it, like it

Link: I found this function here

Written by lutsen

August 19, 2008 at 11:37 am

Posted in Actionscript, Web

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: