Home » ActionScript 2.0, ActionScript 3.0

Search and Replace String AS2/AS3:

16 October 2008 One Comment

Today i came across the jptarry Blog and i found one intersting string replace function.

Split function splits at the given string and join method inserts and concats..

var str:String = strReplace(”this is a test page to replace this from the sentence”,”this”, “THIS”);
trace(str)
function strReplace($str:String, $search:String, $replace:String):String {
return $str.split($search).join($replace);
}

//outputs as “THIS is a test page to replace THIS from the sentence”

VN:F [1.7.7_1013]
Rating: 0.0/10 (0 votes cast)
VN:F [1.7.7_1013]
Rating: 0 (from 0 votes)
Translate this post
        
        
        
        
  

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.