27.06.2011, 15:33
What about this, Double-O-Seven?
Code:
stock strreplace2(string[], const find[], const replace[], bool:ignorecase=false, count=cellmax, maxlength=sizeof(string)) { if(isnull(find) || isnull(string)) return 0; new matches; for(new idx, flen = strlen(find), rlen = strlen(replace), pos = strfind(string, find, ignorecase); pos != -1 && idx < maxlength && matches < count; pos = strfind(string, find, ignorecase, idx)) { strdel(string, pos, pos + flen); if(rlen) strins(string, replace, pos, maxlength); idx = pos + rlen; matches++; } return matches; }