Replaces substrings in a string.
StringReplace ( "string", "searchstring/start", "replacestring" [, occurrence = 0 [, casesense = 0]] )
By default or if the occurrence is positive the search/replace is performed left-to-right. Thus, StringReplace("aaa", "aa", "bb") returns "bba"
If the start method is used the occurrence and casesense parameters are ignored. The function will replace the characters in "string", starting at the requested position, with the characters in "replacestring" - as many characters will be replaced as are in "replacestring". However, if there are not enough characters in "string" for the entire "replacestring" to be inserted an empty string is returned and @error is set to 1.
If performing a non-case sensitive ($STR_NOCASESENSE) replacement on a long string, execution time might be reduced by using StringRegExpReplace() with the leading (?i) option. Note that in this case RegEx metacharacters \ . ^ $ | [ ( { * + ? # must be escaped by using a preceding \. See example 2 for performance differences.
StringAddCR, StringLeft, StringLen, StringLower, StringMid, StringRight, StringStripWS, StringTrimLeft, StringTrimRight, StringUpper, StringRegExpReplace
#include <MsgBoxConstants.au3>
; Replace a blank space (' ') with a - (minus) character.
Local $sString= StringReplace ("This is a sentence with whitespace."," ","-")
Local $iReplacements= @extended
MsgBox ($MB_SYSTEMMODAL,"",$iReplacements&" replacements were made and the new string is:"&@CRLF &@CRLF &$sString)