$ npm install @stdlib/string
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
String manipulation functions.
npm install @stdlib/string
var string = require( '@stdlib/string' );
Namespace containing string manipulation functions.
var str = string;
// returns {...}
The namespace exposes the following string manipulation functions:
acronym( str[, options] )
: generate an acronym for a given string.base
: base (i.e., lower-level) string functions.camelcase( str )
: convert a string to camel case.capitalize( str )
: capitalize the first character in a string.codePointAt( string, position[, backward] )
: return a Unicode code point from a string at a specified position.constantcase( str )
: convert a string to constant case.dotcase( str )
: convert a string to dot case.endsWith( str, search[, len] )
: test if a string ends with the characters of another string.first( str[, n][, options] )
: return the first character(s) of a string.forEach( str, [options,] clbk[, thisArg ] )
: invokes a function for each character in a string.format( str, ...args )
: insert supplied variable values into a format string.fromCodePoint( pt1[, pt2[, pt3[, ...]]] )
: create a string from a sequence of Unicode code points.headercase( str )
: convert a string to HTTP header case.kebabcase( str )
: convert a string to kebab case.last( str[, n][, options] )
: return the last character(s) of a string.lpad( str, len[, pad] )
: left pad a string.ltrimN( str, n[, chars] )
: trim n
characters from the beginning of a string.ltrim( str )
: trim whitespace characters from the beginning of a string.lowercase( str )
: convert a string to lowercase.nextCodePointIndex( string[, fromIndex] )
: return the position of the next Unicode code point in a string after a specified position.nextGraphemeClusterBreak( string[, fromIndex] )
: return the next extended grapheme cluster break in a string after a specified position.numGraphemeClusters( str )
: return the number of grapheme clusters in a string.num2words( value[, options] )
: convert a number to a word representation.pad( str, len[, options] )
: pad a string.pascalcase( str )
: convert a string to Pascal case.percentEncode( str )
: percent-encode a UTF-16 encoded string according to RFC 3986.prevGraphemeClusterBreak( string[, fromIndex] )
: return the previous extended grapheme cluster break in a string before a specified position.removeFirst( str[, n][, options] )
: remove the first character(s) of a string.removeLast( str[, n][, options] )
: remove the last character(s) of a string.removePunctuation( str )
: remove punctuation characters from a string.removeUTF8BOM( str )
: remove a UTF-8 byte order mark (BOM) from the beginning of a string.removeWords( str, words[, ignoreCase] )
: remove a list of words from a string.repeat( str, n )
: repeat a string a specified number of times and return the concatenated result.replaceBefore( str, search, replacement )
: replace the substring before the first occurrence of a specified search string.replace( str, search, newval )
: replace search occurrences with a replacement string.reverse( str[, options] )
: reverse a string.rpad( str, len[, pad] )
: right pad a string.rtrimN( str, n[, chars] )
: trim n
characters from the end of a string.rtrim( str )
: trim whitespace characters from the end of a string.snakecase( str )
: convert a string to snake case.splitGraphemeClusters( str )
: split a string by its grapheme cluster breaks.startcase( str )
: capitalize the first letter of each word in a string.startsWith( str, search[, position] )
: test if a string starts with the characters of another string.substringAfterLast( str, search[, fromIndex] )
: return the part of a string after the last occurrence of a specified substring.substringAfter( str, search[, fromIndex] )
: return the part of a string after a specified substring.substringBeforeLast( str, search )
: return the part of a string before the last occurrence of a specified substring.substringBefore( str, search )
: return the part of a string before a specified substring.graphemeClusters2iteratorRight( src[, mapFcn[, thisArg]] )
: create an iterator which iterates from right to left over grapheme clusters.graphemeClusters2iterator( src[, mapFcn[, thisArg]] )
: create an iterator which iterates over grapheme clusters.toWellFormed( str )
: create a new well-formed string.trim( str )
: trim whitespace characters from the beginning and end of a string.truncateMiddle( str, len[, seq] )
: truncate a string in the middle to a specified length.truncate( str, len[, ending] )
: truncate a string to a specified length.uncapitalize( str )
: uncapitalize the first character of a string.uppercase( str )
: convert a string to uppercase.utf16ToUTF8Array( str )
: convert a UTF-16 encoded string to an array of integers using UTF-8 encoding.var getKeys = require( '@stdlib/utils/keys' );
var string = require( '@stdlib/string' );
console.log( getKeys( string ) );
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.
See LICENSE.
Copyright © 2016-2024. The Stdlib Authors.
© 2010 - cnpmjs.org x YWFE | Home | YWFE