.Modelica.Utilities.Strings

Information

Library content

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.

Contents

Name Description
 length Return length of string
 substring Return a substring defined by start and end index
 repeat Repeat a string n times
 compare Compare two strings lexicographically
 isEqual Determine whether two strings are identical
 isEmpty Return true if a string is empty (has only white space characters)
 count Count the number of non-overlapping occurrences of a string
 find Find first occurrence of a string within another string
 findLast Find last occurrence of a string within another string
 replace Replace non-overlapping occurrences of a string from left to right
 sort Sort vector of strings in alphabetic order
 hashString Create a hash value of a string
 scanToken Scan for the next token and return it
 scanReal Scan for the next Real number and trigger an assert if not present
 scanInteger Scan for the next Integer number and trigger an assert if not present
 scanBoolean Scan for the next Boolean number and trigger an assert if not present
 scanString Scan for the next Modelica string and trigger an assert if not present
 scanIdentifier Scan for the next Identifier and trigger an assert if not present
 scanDelimiter Scan for the next delimiter and trigger an assert if not present
 scanNoToken Scan string and check that it contains no more token
 syntaxError Print an error message, a string and the index at which scanning detected an error
 Advanced Advanced scanning functions

Generated at 2020-06-05T21:39:08Z by OpenModelica 1.16.0~dev-442-g2e5bc9f