functioncontains
Check if a string contains a substring
Extends from Modelica.Icons.Function (Icon for functions).
Information
Syntax
result = Strings.contains(string, searchString); result = Strings.contains(string, searchString, caseSensitive);
Description
Returns true if "searchString" is a substring of "string". Otherwise, false is returned. The optional argument "caseSensitive" controls if substrings match, which differ in case only.
Empty strings are treated as substring of all strings. Therefore, the result is always true if "searchString" is empty.
Example
import Modelica.Utilities.Strings.contains;
contains("foobar", "OO"); // returns false
contains("foobar", "OO", false); // returns true
contains("foo", "bar"); // returns false
contains("", ""); // returns true
contains("foo", ""); // returns true
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| String | string | String to check | |
| String | searchString | Substring to look for | |
| Boolean | caseSensitive | true | = false, if lower and upper case are ignored for the search |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Boolean | result | = true, if searchString can be found anywhere in string |