Replace a word with another.
#6

pawn Code:
strreplace(some string, "Hello", "Hola");
pawn 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;
}
Reply


Messages In This Thread
Replace a word with another. - by Zh3r0 - 05.02.2011, 20:09
Re: Replace a word with another. - by xRyder - 05.02.2011, 20:20
Re: Replace a word with another. - by Zh3r0 - 05.02.2011, 20:23
Re: Replace a word with another. - by Mauzen - 05.02.2011, 20:28
Re: Replace a word with another. - by Hiddos - 05.02.2011, 20:29
Re: Replace a word with another. - by [03]Garsino - 05.02.2011, 20:31

Forum Jump:


Users browsing this thread: 2 Guest(s)