The following lists alphabetically built-in PTL functions available for manipulating and working with strings.
These functions are placed in Strings package.
IsDigit
Indicates whether the specified character is categorized as a decimal digit.
Syntax
Parameters
StringAppend
Appends the specified string to the end of the string, and returns the resulting string.
Syntax
Parameters
Example
string str;
str = StringAppend("comp", "iler"); // str <- "compiler"
StringBuild
Creates a new string to the value indicated by a specified character or string repeated a specified number of times
Syntax
Parameters
Example
string str;
str = StringBuild('a', 4); // str <- "aaaa"
StringEntries
Return the count of entries the specified symbol into the sprcified string
Syntax
StringFind
Searches for the specified substring and returns the position of its first occurrence in the string. If no specified substring is found, the NOT_FOUND constant is returned (NOT_FOUND equal to (-1)).
Syntax
|
int StringFind( string text, string pattern) int StringFind( string text, char pattern) int StringFind( string text, string pattern, int startPos) int StringFind( string text, string pattern, int startPos, int count) int StringFind( string text, char pattern, int startPos) int StringFind( string text, char pattern, int startPos, int count) |
Parameters
Example
int res;
res = StringFind("xyzababc2354", "abc"); // res <- 5
res = StringFind("123", "abc"); // res <- NOT_FOUND
res = StringFind("abxyzababc2354", 'a', 3); // res <- 5
res = StringFind("1234567890ab", 'a', 0, 5); // res <- NOT_FOUND
StringInsert
Inserts the specified substring in the specified position of the string, and returns the resulting string.
Syntax
|
string StringInsert( string text, int pos, string stringToInsert) |
Parameters
Example
string res;
res = StringInsert("abc", 1, "123"); // res <- "a123bc"
StringRemove
Removes the substring of specified length starting from the specified position from the string, and returns the resulting string.
Syntax
Parameters
Example
string str;
str = StringRemove("abc123xyz", 3, 3); // str <- "abcxyz"
str = StringRemove("abc123xyz", 3); // str <- "abc"
StringRemoveFirst
Removes the first character (or substring of the specified length) from the beginning of the string, and returns the resulting string.
Syntax
Parameters
Example
string str;
str = StringRemoveFirst("abc123xyz"); // str <- "bc123xyz"
str = StringRemoveFirst("abc123xyz", 2); // str <- "c123xyz"
StringRemoveLast
Removes the last character (or substring of the specified length) from the end of the string, and returns the resulting string.
Syntax
Parameters
Example
string str;
str = StringRemoveLast("abc123xyz"); // str <- "abc123xy"
str = StringRemoveLast("abc123xyz",2); // str <- "abc123x"
StringReplace
Replaces all occurrences of the specified substring in the string with the new substring, and returns the resulting string.
Syntax
Parameters
Example
string str;
str = StringRemoveLast("abc123abc", "abc", "wxyz"); // str <- "wxyz123wxyz"
StringSplit
Returns a string array that contains the substrings in this instance that are delimited by specified character.
Syntax
|
void StringSplit( string[] array, string baseString, char delimiter) void StringSplit( string[] array, string baseString, char delimiter, bool removeEmptyEntries) |
StringStartsWith
Returns true if the specified string starts with the specified substring, and false otherwise.
Syntax
Parameters
Example
bool res;
res = StringStartsWith("abc123abc", "ab"); // res <- True
res = StringStartsWith("abc123abc", "12"); // res <- False
StringSubst
Returns the substring of specified length starting from the specified position of the string.
Syntax
Parameters
Example
string str;
str = StringSubst("abc123abc", 5, 2); // str <- "3a"
str = StringSubst("abc123abc", 5); // str <- "3abc"
StringTrimLeft
Trims whitespace characters (spaces, tabs, line feeds, carriage returns) from the left-hand side of the string, and returns the trimmed string.
Syntax
Parameters
Example
string str;
str = StringTrimLeft(" abc"); // str <- "abc"
StringTrimRight
Trims whitespace characters (spaces, tabs, line feeds, carriage returns) from the right-hand side of the string, and returns the trimmed string.
Syntax
Parameters
Example
string str;
str = StringTrimRight("abc "); // str <- "abc"