05.02.2011, 20:09
I tried different types of code...couldn't make it work...
Any ideas ? I tried strreplace...not working...
Any ideas ? I tried strreplace...not working...
new s1[128] = "I'm eating cakes";
new s2[] = "shitting";
strdel(s1, 4, 10);
strins(s1, s2, 4);
print(s1);
Not sure if this will help, but you can use strdel and strins.
Example: (I found it somewhere around here) pawn Code:
|
strreplace(some string, "Hello", "Hola");
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;
}