Strlib:str-ireplace

From SA-MP Wiki

Jump to: navigation, search


Description:

The function str_ireplace allows you to replace a string with another string in one huge string. (Case insensitive)


Image:32px-Circle-style-warning.png

Warning

This function is part of the strlib library. Click here to view its download page on the SA-MP forums.



Parameters:
(sSearch[], sReplace[], sSubject, &iCount)
sSearch[]The string you want to remove.
sReplace[]The string you want to replace it with.
sSubject[]The string you want to replace it with.
&iCountOptional integer with the amount of times the string has been replaced.

Return Values:

String that has been replaced.


Example

new
    sSearch[] = "red",               // String you want to search for
    sReplace[] = "yellow",           // String you want to replace it with
    sSubject[] = "The red lorry jumped over Red, the redneck from Nebraska.";
 
print("%s", str_ireplace(sSearch, sReplace, sSubject));

Output

The yellow lorry jumped over yellow, the yellowneck from Nebraska.
(It differs from str_replace in the case that it is case insensitive, and 'Red' gets replaced.)
Personal tools