String Search & Replace (AS2 & AS3)


function strReplace($str:String, $search:String, $replace:String):String
{
return $str.split($search).join($replace);
}
var str:String = new String();
str = "we are Khmer!"
trace(strReplace(str,"we","We"));

The "split" function splits the string at the word ($search) you're searching for. And the "join" inserts the new word ($replace) between the elements, concatenates them, and returns the resulting string

Comments

Popular posts from this blog

PHP: Date Difference for PHP 5.2

HTML5 video loop src change on end play function

Custom OpenCart 2.3.0.2 theme