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

String.endsWith

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

Description

Check that the end of the string matches $matchString.

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

'abcdef'.endsWith('def')
//= true

'abcdef'.endsWith('DEF')
//= false

'abcdef'.endsWith('DEF', -ignoreCase)
//= true

Regex Patterns

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

// $ = end of string
'abc 123'.match(r'\d+$')
//= '123'

// i = ignore case
'Abc Xyz'.match(r'(def|xyz)$'i)
//= 'Xyz'

See Also