StringsOperations on strings |
Return length of string |
|
Return a substring defined by start and end index |
|
Repeat a string n times |
|
Compare two strings lexicographically |
|
Determine whether two strings are identical |
|
Return true if a string is empty (has only white space characters) |
|
Count the number of non-overlapping occurrences of a string |
|
Find first occurrence of a string within another string |
|
Find last occurrence of a string within another string |
|
Replace non-overlapping occurrences of a string from left to right |
|
Sort vector of strings in alphabetic order |
|
Create a hash value of a string |
|
Scan for the next token and return it |
|
Scan for the next Real number and trigger an assert if not present |
|
Scan for the next Integer number and trigger an assert if not present |
|
Scan for the next Boolean number and trigger an assert if not present |
|
Scan for the next Modelica string and trigger an assert if not present |
|
Scan for the next Identifier and trigger an assert if not present |
|
Scan for the next delimiter and trigger an assert if not present |
|
Scan string and check that it contains no more token |
|
Print an error message, a string and the index at which scanning detected an error |
|
Advanced scanning functions |
This information is part of the Modelica Standard Library maintained by the Modelica Association.
Package Strings contains functions to manipulate strings.
In the table below an example call to every function is given using the default options.
Function | Description |
---|---|
len = length(string) | Returns length of string |
string2 = substring(string1,startIndex,endIndex) | Returns a substring defined by start and end index |
result = repeat(n) result = repeat(n,string) |
Repeat a blank or a string n times. |
result = compare(string1, string2) | Compares two substrings with regards to alphabetical order |
identical = isEqual(string1,string2) | Determine whether two strings are identical |
result = count(string,searchString) | Count the number of occurrences of a string |
index = find(string,searchString) | Find first occurrence of a string in another string |
index = findLast(string,searchString) | Find last occurrence of a string in another string |
string2 = replace(string,searchString,replaceString) | Replace one or all occurrences of a string |
stringVector2 = sort(stringVector1) | Sort vector of strings in alphabetic order |
hash = hashString(string) | Create a hash value of a string |
(token, index) = scanToken(string,startIndex) | Scan for a token (Real/Integer/Boolean/String/Identifier/Delimiter/NoToken) |
(number, index) = scanReal(string,startIndex) | Scan for a Real constant |
(number, index) = scanInteger(string,startIndex) | Scan for an Integer constant |
(boolean, index) = scanBoolean(string,startIndex) | Scan for a Boolean constant |
(string2, index) = scanString(string,startIndex) | Scan for a String constant |
(identifier, index) = scanIdentifier(string,startIndex) | Scan for an identifier |
(delimiter, index) = scanDelimiter(string,startIndex) | Scan for delimiters |
scanNoToken(string,startIndex) | Check that remaining part of string consists solely of white space or line comments ("// ...\n"). |
syntaxError(string,index,message) | Print a "syntax error message" as well as a string and the index at which scanning detected an error |
The functions "compare", "isEqual", "count", "find", "findLast", "replace", "sort" have the optional input argument caseSensitive with default true. If false, the operation is carried out without taking into account whether a character is upper or lower case.