startsWith

startsWith, function

def const pure startsWith(source: text, pattern: text): boolean

Returns true if the source starts with an occurrence of the pattern.

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.

See also

User Contributed Notes
0 notes + add a note