Test if a string ends with the characters of another string.
var endsWith = require( '@stdlib/string/ends-with' );
Tests if a string
ends with the characters of another string
.
var str = 'Remember the story I used to tell you when you were a boy?';
var out = endsWith( str, 'boy?' );
// returns true
out = endsWith( str, 'Boy?' );
// returns false
By default, the function searches from the end of the input string
. To search from a different position, provide a position
value.
var str = 'To be, or not to be, that is the question.'
var out = endsWith( str, 'to be', 19 );
// returns true
var endsWith = require( '@stdlib/string/ends-with' );
var str;
var out;
str = 'Fair is foul, and foul is fair, hover through fog and filthy air';
out = endsWith( str, 'air' );
// returns true
out = endsWith( str, 'fair' );
// returns false
out = endsWith( str, 'fair', 30 );
// returns true
Usage: ends-with [options] --search=string string
Options:
-h, --help Print this message.
-V, --version Print the package version.
--search string Search string.
--pos int Search position.
$ ends-with --search='ep' beep
true