Version: v0.7.0 - 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

If you need to match a pattern at the beginning of the string, you can use match with the ^ anchor instead.

// ^ = beginning of string
'123 abc'.match(r'^\d+')
//= '123'

// i = ignore case
'Abc 123'.match(r'^(abc|xyz)'i)
//= 'Abc'

See Also