ReplaceStringEx Function

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

int ReplaceStringEx(char[] text, int maxlength, const char[] search, const char[] replace, int searchLen, int replaceLen, bool caseSensitive)

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

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

Errors

'search' parameter is empty.