/*
Case insensitive string_replace() script
Creator: Big J
Date: 02/09/2008
Description: Replaces one or all occurrences of a sub string within a string
Arg 0: String
Arg 1: Sub String
Arg 2: New String to replace Sub String with
Arg 3: Whether to replace ALL occurrences
*/
var str, substr, newstr, pos, str2, substr2, replace_all, len, temp;
str = argument0;
substr = argument1;
newstr = argument2;
replace_all = argument3;
str2 = string_lower(str);
substr2 = string_lower(substr);
while (true)
{
len = string_length(substr);
pos = string_pos(substr2, str2);
if (pos)
{
temp = string_copy(str, pos, len);
str = string_replace(str, temp, newstr);
str2 = string_replace(str2, substr2, newstr);
}
else
break;
if (!replace_all)
break;
}
return str;
Comments