Replace (Function) In french: Remplace Replaces all occurrences of a specified substring in a string with another specified substring. Remark: The initial character string is not modified.
InitialString is string = "Abracadabra!" ReplacedString is string = Replace(InitialString, "a", "o") Info(ReplacedString) // Displays "Abrococobro!"
Syntax
Replacing a string with another string Hide the details
<Result> = Replace(<Initial string> , <String to replace> , <New string> [, <Option>])
<Result>: Character string New string in which the specified strings have been replaced. <Initial string>: Character string String in which the specified strings will be replaced (maximum size: 2 GB). <String to replace>: Character string String to be replaced in the initial string. If this parameter corresponds to an empty string (""), <Result> will correspond to <Initial string>. <New string>: Character string String that will replace <String to replace>. If this parameter corresponds to an empty string (""), all the occurrences of <String to replace> will be deleted. <Option>: Optional constant (or combination of constants) Indicates the characteristics of the search for the word to replace: | | IgnoreCase | Case and accent insensitive search (ignores uppercase and lowercase differences). | WholeWord | Searches for a whole word (between punctuation characters or spaces) |
By default, the search is case-sensitive: the search string must have the same case as the string to find in the initial string. To perform a case-insensitive search, use the IgnoreCase constant. Remarks <Initial string>, <String to replace> and <New string> can correspond to: - ANSI strings.
- UNICODE strings.
- buffers.
You have the ability to use ANSI strings, Unicode strings and buffers in the different parameters of the function. The following conversion rule is used for the Ansi systems (Windows or Linux): - If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers.
- If the first condition is not met and there is at least one Unicode string, all the strings are converted to Unicode and the operation is performed in Unicode (the conversion is performed with the current character set, if necessary).
- Otherwise, the operation is performed in Ansi.
The conversion rule used for Unicode systems is as follows: - If at least one of the strings is a buffer, all the strings are converted to buffers and the operation is performed with buffers.
- Otherwise, the operation is performed in Unicode.
Reminder: The linguistic parameters used are defined during the call to ChangeCharset.
This page is also available for…
|
|
|
|