I have this as3 function
public static function StringReplaceAll( source:String, find:String, replacement:String ) : String {
return source.split( find ).join( replacement );
}
Works fine: any idea how to make it case insenstive ? Regards
Just use the String#replace() function.
for example:
trace("HELLO there".replace(/e/gi, "a"));
//traces HaLLO thara
The first argument in the replace function is a regular expression. You'll find information about them all over the web. And there's this handy tool from Grant Skinner called Regexr with which you can test your regular expressions ActionScript style.
The part between the two forward slashes (/) is the actual regex.
Note that /e/gi
is actually just a shorthand for new RegExp("e", "gi")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With