ReplaceStringEx

Last Updated2021-06-24
Created At2007-05-22

Given a string, replaces the first occurrence of a search string with a replacement string.

native int ReplaceStringEx(char[] text, int maxlength, const char[] search, const char[] replace, int searchLen = -1, int replaceLen = -1, bool caseSensitive = true)

Parameters

char[] text
String to perform search and replacements on.
int maxlength
Maximum length of the string buffer.
const char[] search
String to search for.
const char[] replace
String to replace the search string with.
int searchLen
If higher than -1, its value will be used instead of a strlen() call on the search parameter.
int replaceLen
If higher than -1, its value will be used instead of a strlen() call on the replace parameter.
bool caseSensitive
If true (default), search is case sensitive.

Return Value

int Index into the buffer (relative to the start) from where the last replacement ended, or -1 if no replacements were made.

Error

'search' parameter is empty.