Description
The contains function checks whether the string haystack contains the substring needle. It returns true if needle is found, otherwise false. If the optional parameter ignoreCase is set to 1, case sensitivity is ignored.
Note: Cannot be persisted using persist.
Syntax
contains(haystack, needle[, ignoreCase])
Arguments
| Argument | Description |
|---|---|
haystack |
The string in which to search. |
needle |
The substring to search for within haystack. |
ignoreCase (optional) |
Indicates whether case sensitivity should be ignored. 1 means the check is case-insensitive, 0 or omitted means the check is case-sensitive. |
Return Types
The function returns a boolean value (true or false).
Examples
| Description | Formula | Result |
|---|---|---|
Checks case-sensitive if needle is contained in haystack |
contains("Smenso Rocks", "Rocks")
|
true |
Checks case-sensitive if needle is contained in haystack |
contains("Smenso Rocks", "rocks")
|
false |
Checks case-insensitive if needle is contained in haystack |
contains("Smenso Rocks", "rocks", 1)
|
true |
Notes
- Case sensitivity: By default, the function distinguishes between uppercase and lowercase letters.
- Optional parameters: The
ignoreCaseparameter can be used to disable this distinction.
Comments
0 comments
Please sign in to leave a comment.