Description
The startsWith
function checks whether the string haystack
begins with the substring needle
. It returns true
if this is the case, otherwise false
. If the optional parameter ignoreCase
is set to 1
, case sensitivity is ignored.
Note: Cannot be persisted using persist
.
Syntax
startsWith(haystack, needle[, ignoreCase])
Arguments
Argument | Description |
---|---|
haystack |
The string to be checked. |
needle |
The substring that is expected to be at the beginning of 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 haystack starts with needle |
startsWith("Smenso Rocks", "Smenso") |
true |
Checks case-sensitive if haystack starts with needle |
startsWith("Smenso Rocks", "smenso") |
false |
Checks case-insensitive if haystack starts with needle |
startsWith("Smenso Rocks", "smenso", 1) |
true |
Notes
- Case sensitivity: By default, the function distinguishes between uppercase and lowercase letters.
- Optional parameters: The
ignoreCase
parameter can be used to disable this distinction.
Comments
0 comments
Please sign in to leave a comment.