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

HTML5 video loop src change on end play function

Set limit wp_nav_menu

Calculate percentage of a specific element has been scrolled into visible on the screen