The string change activity offers the delphi stringutils functions to change a string.
Activity properties
Retrurn value is optional in some change functions.
If return value is selected, a new string with the changed value is created.
If return value is not selected, the old string is changed.
Possible change functions:
Adds quotes to the beginning and end of a string;
Example:
String: "The quick brown fox jumps over the lazy dog."
begin var ChangedString: string; ChangedString := StringValue.QuotedString; end; |
Result = "'The quick brown fox jumps over the lazy dog.'"
Removes the quotes from a string at the beginning and the end if present.
Example:
String: "The quick brown fox jumps over the lazy dog.'"
begin var ChangedString: string; ChangedString := StringValue.DeQuotedString; end; |
Result = "The quick brown fox jumps over the lazy dog."
Inserts a string into a string at a given position.
Example:
String = "The quick brown fox jumps over the lazy dog."
String to insert = "test"
Position = 2
begin var ChangedString: string; ChangedString := StringValue.Insert(2, 'test'); end; |
Result = "Thteste quick brown fox jumps over the lazy dog."
Joins an array string with a separator.
Example:
Array = ['the', 'quick', 'brown'];
Separator = -
Position = 1
Number of ietms = 2
begin var ChangedString: string; var ArrayToJoin := StringArray; ChangedString := String.Join('-', ArrayToJoin, 1, 2); end; |
Result = "quick-brown"
Separator is optional
Postion is optional with a default of 0
Number of items is option with a default of everything after position.
Replaces a part of a string with another string.
Example:
String = "the-quick-brown"
Text to replace = '-'
new text = ' '
Replace all = True
Ignore case = False
begin var ChangedString: string; ChangedString := StringValue.Replace('-', ' ', [rfReplaceAll]); end; |
Result = "the quick brown"
Reverses the complete string char by char.
Example:
String: "The quick brown fox jumps over the lazy dog."
begin var ChangedString: string; ChangedString := ReverseString(StringValue); end; |
Result = ".god yzal eht revo spmuj xof nworb kciuq ehT"
converts all chars in a string to lowercase.
Example:
String: "The quick brOwn fox Jumps over The lazy dog."
begin var ChangedString: string; ChangedString := LowerCase(StringValue); end; |
Result = "the quick brown fox jumps over the lazy dog."
converts all chars in a string to uppercase.
Example:
String: "The quick brOwn fox Jumps over The lazy dog."
begin var ChangedString: string; ChangedString := LowerCase(StringValue); end; |
Result = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG."