Version: v0.8.1 - Beta.  We welcome contributors & feedback.

String.startsWith

startsWith($matchString, $options={}) -> boolean

Description

Check that the beginning of the string matches $matchString.

If $options is -ignoreCase it will match both upper and lowercase versions of each character.

'abcdef'.startsWith('abc')
//= true

'abcdef'.startsWith('ABC')
//= false

'abcdef'.startsWith('ABC', -ignoreCase)
//= true

Regex Patterns

The $matchString argument can also be a Regex.

// \d+ = one or more digits
'123 abc'.startsWith(rx'\d+')
//= true

// i = ignore case
'Abc 123'.startsWith(rx'(abc|def)'i)
//= true

See Also