Navigation :
startsWith
startsWith, function
def const pure startsWith(source: text, pattern: text): boolean
Returns true
if the source
starts with an occurrence of the pattern
.
source
: The text in which pattern
should be looked for
pattern
: The text to look for inside source
Example
table T = with
[| as Source , as Pattern |]
[| "Hello world!" , "Hello" |]
[| "Hello world!" , "hello" |]
[| "Hello world!" , "" |]
[| "" , "" |]
T.Result = startsWith(T.Source, T.Pattern)
show table "T" with
T.Source
T.Pattern
T.Result
This outputs the following table :
Source |
Pattern |
Result |
Hello world! |
Hello |
true |
Hello world! |
hello |
false |
Hello world! |
|
true |
|
|
true |
This function is case-sensitive, as illustrated hereinabove.
Using startsWith
with an empty pattern will always return true
.
See also