Skip to content

Latest commit

 

History

History

ends-with

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

endsWith

Test if a string ends with the characters of another string.

Usage

var endsWith = require( '@stdlib/string/ends-with' );

endsWith( str, search[, position] )

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

Examples

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

CLI

Usage

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.

Examples

$ ends-with --search='ep' beep
true