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 whichpattern
should be looked forpattern
: The text to look for insidesource
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 |
Remarks
This function is case-sensitive, as illustrated hereinabove.
Using startsWith
with an empty pattern will always return true
.