Strlib:str-replace

From SA-MP Wiki

(Redirected from Strlib/str replace)
Jump to: navigation, search


Description:

The function str_replace allows you to replace a string with another string in one huge string.


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_replace(sSearch, sReplace, sSubject));

Output

The yellow lorry jumped over Red, the yellowneck from Nebraska.
(note it is case sensitive!)
Personal tools
Navigation
Toolbox