0.2.2 • Published 10 months ago
@stdlib/string-base-remove-last-grapheme-cluster v0.2.2
removeLastGraphemeCluster
Remove the last
n
grapheme clusters (i.e., user-perceived characters) of a string.
Installation
npm install @stdlib/string-base-remove-last-grapheme-cluster
Usage
var removeLastGraphemeCluster = require( '@stdlib/string-base-remove-last-grapheme-cluster' );
removeLastGraphemeCluster( str, n )
Removes the last n
grapheme clusters (i.e., user-perceived characters) of a string.
var out = removeLastGraphemeCluster( 'last man standing', 1 );
// returns 'last man standin'
out = removeLastGraphemeCluster( 'Hidden Treasures', 1 );
// returns 'Hidden Treasure'
out = removeLastGraphemeCluster( 'foo bar', 5 );
// returns 'fo'
out = removeLastGraphemeCluster( 'foo bar', 10 );
// returns ''
Examples
var removeLastGraphemeCluster = require( '@stdlib/string-base-remove-last-grapheme-cluster' );
var str = removeLastGraphemeCluster( 'presidential election', 1 );
// returns 'presidential electio'
str = removeLastGraphemeCluster( 'JavaScript', 1 );
// returns 'JavaScrip'
str = removeLastGraphemeCluster( 'The Last of the Mohicans', 5 );
// returns 'The Last of the Moh'
str = removeLastGraphemeCluster( '🐶🐮🐷🐰🐸', 2 );
// returns '🐶🐮🐷'
str = removeLastGraphemeCluster( '🐶🐮🐷🐰🐸', 10 );
// returns ''
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.