A quick way may be to make two replacements. One for lowerCase and one for upperCase. It will look something like this:
public static function StringReplaceAll( source:String, find:String, replacement:String ) : String { var replacedLowerCase:String = StringReplace(source, find.toLowerCase(), replacement.toLowerCase()); return StringReplace(replacedLowerCase, find.toUpperCase(), replacement.toUpperCase()); } private static function StringReplace( source:String, find:String, replacement:String ) : String { return source.split(find).join(replacement); }
So, in this case, you save the case of your find intact ie:
trace(StringReplaceAll('HELLO there', 'e', 'a'));
If you do not want this argument to be intact, @RIAstar String.replace() answer was cleaner. (But you could, of course, also use his example twice in this regard)
source share