# String Manipulation

[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] 

> String manipulation functions.

## Installation

```bash
npm install @stdlib/string
```

Alternatively,

-   To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm` branch][esm-url].
-   If you are using Deno, visit the [`deno` branch][deno-url].
-   For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd` branch][umd-url].

The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships.

## Usage

```javascript
var string = require( '@stdlib/string' );
```

#### string

Namespace containing string manipulation functions.

```javascript
var str = string;
// returns {...}
```

The namespace exposes the following string manipulation functions:

-   [`acronym( str[, options] )`][@stdlib/string/acronym]: generate an acronym for a given string.
-   [`camelcase( str )`][@stdlib/string/camelcase]: convert a string to camel case.
-   [`capitalize( str )`][@stdlib/string/capitalize]: capitalize the first character in a string.
-   [`codePointAt( string, position[, backward] )`][@stdlib/string/code-point-at]: return a Unicode code point from a string at a specified position.
-   [`constantcase( str )`][@stdlib/string/constantcase]: returns a string converted to a constant case.
-   [`endsWith( str, search[, len] )`][@stdlib/string/ends-with]: test if a string ends with the characters of another string.
-   [`fromCodePoint( pt1[, pt2[, pt3[, ...]]] )`][@stdlib/string/from-code-point]: create a string from a sequence of Unicode code points.
-   [`kebabcase( str )`][@stdlib/string/kebabcase]: convert a string to kebab case.
-   [`lpad( str, len[, pad] )`][@stdlib/string/left-pad]: left pad a string.
-   [`ltrimN( str, n[, chars] )`][@stdlib/string/left-trim-n]: trim `n` characters from the end of a string.
-   [`ltrim( str )`][@stdlib/string/left-trim]: trim whitespace characters from the beginning of a string.
-   [`lowercase( str )`][@stdlib/string/lowercase]: convert a string to lowercase.
-   [`nextGraphemeClusterBreak( string[, fromIndex] )`][@stdlib/string/next-grapheme-cluster-break]: return the next extended grapheme cluster break in a string after a specified position.
-   [`numGraphemeClusters( str )`][@stdlib/string/num-grapheme-clusters]: return the number of grapheme clusters in a string.
-   [`pad( str, len[, options] )`][@stdlib/string/pad]: pad a string.
-   [`pascalcase( str )`][@stdlib/string/pascalcase]: convert a string to Pascal case.
-   [`percentEncode( str )`][@stdlib/string/percent-encode]: percent-encode a UTF-16 encoded string according to RFC 3986.
-   [`prevGraphemeClusterBreak( string[, fromIndex] )`][@stdlib/string/prev-grapheme-cluster-break]: return the previous extended grapheme cluster break in a string before a specified position.
-   [`removeFirst( str[, n] )`][@stdlib/string/remove-first]: remove the first character(s) of a string.
-   [`removeLast( str[, n] )`][@stdlib/string/remove-last]: remove the last character(s) of a string.
-   [`removePunctuation( str )`][@stdlib/string/remove-punctuation]: remove punctuation characters from a string.
-   [`removeUTF8BOM( str )`][@stdlib/string/remove-utf8-bom]: remove a UTF-8 byte order mark (BOM) from the beginning of a string.
-   [`removeWords( str, words[, ignoreCase] )`][@stdlib/string/remove-words]: remove a list of words from a string.
-   [`repeat( str, n )`][@stdlib/string/repeat]: repeat a string a specified number of times and return the concatenated result.
-   [`replace( str, search, newval )`][@stdlib/string/replace]: replace search occurrences with a replacement string.
-   [`reverseString( str )`][@stdlib/string/reverse]: reverse a string.
-   [`rpad( str, len[, pad] )`][@stdlib/string/right-pad]: right pad a string.
-   [`rtrimN( str, n[, chars] )`][@stdlib/string/right-trim-n]: trim `n` characters from the end of a string.
-   [`rtrim( str )`][@stdlib/string/right-trim]: trim whitespace characters from the end of a string.
-   [`snakecase( str )`][@stdlib/string/snakecase]: convert a string to snake case.
-   [`splitGraphemeClusters( str )`][@stdlib/string/split-grapheme-clusters]: split a string by its grapheme cluster breaks.
-   [`startcase( str )`][@stdlib/string/startcase]: capitalize the first letter of each word in a string.
-   [`startsWith( str, search[, position] )`][@stdlib/string/starts-with]: test if a string starts with the characters of another string.
-   [`substringAfterLast`][@stdlib/string/substring-after-last]: return the part of a string after the last occurrence of a specified substring.
-   [`substringAfter( str, search[, fromIndex] )`][@stdlib/string/substring-after]: return the part of a string after a specified substring.
-   [`substringBeforeLast( str, search )`][@stdlib/string/substring-before-last]: return the part of a string before the last occurrence of a specified substring.
-   [`substringBefore( str, search )`][@stdlib/string/substring-before]: return the part of a string before a specified substring.
-   [`trim( str )`][@stdlib/string/trim]: trim whitespace characters from the beginning and end of a string.
-   [`truncateMiddle( str, len[, seq] )`][@stdlib/string/truncate-middle]: truncate a string in the middle to a specified length.
-   [`truncate( str, len[, ending] )`][@stdlib/string/truncate]: truncate a string to a specified length.
-   [`uncapitalize( str )`][@stdlib/string/uncapitalize]: uncapitalize the first character of a string.
-   [`uppercase( str )`][@stdlib/string/uppercase]: convert a string to uppercase.
-   [`utf16ToUTF8Array( str )`][@stdlib/string/utf16-to-utf8-array]: convert a UTF-16 encoded string to an array of integers using UTF-8 encoding.

## Examples

```javascript
var getKeys = require( '@stdlib/utils/keys' );
var string = require( '@stdlib/string' );

console.log( getKeys( string ) );
```


* * *

## Notice

This package is part of [stdlib][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][stdlib], see the main project [repository][stdlib].

#### Community

[![Chat][chat-image]][chat-url]

---

## License

See [LICENSE][stdlib-license].

## Copyright

Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].

[npm-image]: http://img.shields.io/npm/v/@stdlib/string.svg
[npm-url]: https://npmjs.org/package/@stdlib/string

[test-image]: https://github.com/stdlib-js/string/actions/workflows/test.yml/badge.svg?branch=v0.0.14
[test-url]: https://github.com/stdlib-js/string/actions/workflows/test.yml?query=branch:v0.0.14

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/string?branch=main

[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
[chat-url]: https://gitter.im/stdlib-js/stdlib/

[stdlib]: https://github.com/stdlib-js/stdlib

[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors

[umd]: https://github.com/umdjs/umd
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules

[deno-url]: https://github.com/stdlib-js/string/tree/deno
[umd-url]: https://github.com/stdlib-js/string/tree/umd
[esm-url]: https://github.com/stdlib-js/string/tree/esm
[branches-url]: https://github.com/stdlib-js/string/blob/main/branches.md

[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/string/main/LICENSE

[@stdlib/string/acronym]: https://github.com/stdlib-js/string/tree/main/acronym

[@stdlib/string/camelcase]: https://github.com/stdlib-js/string/tree/main/camelcase

[@stdlib/string/capitalize]: https://github.com/stdlib-js/string/tree/main/capitalize

[@stdlib/string/code-point-at]: https://github.com/stdlib-js/string/tree/main/code-point-at

[@stdlib/string/constantcase]: https://github.com/stdlib-js/string/tree/main/constantcase

[@stdlib/string/ends-with]: https://github.com/stdlib-js/string/tree/main/ends-with

[@stdlib/string/from-code-point]: https://github.com/stdlib-js/string/tree/main/from-code-point

[@stdlib/string/kebabcase]: https://github.com/stdlib-js/string/tree/main/kebabcase

[@stdlib/string/left-pad]: https://github.com/stdlib-js/string/tree/main/left-pad

[@stdlib/string/left-trim-n]: https://github.com/stdlib-js/string/tree/main/left-trim-n

[@stdlib/string/left-trim]: https://github.com/stdlib-js/string/tree/main/left-trim

[@stdlib/string/lowercase]: https://github.com/stdlib-js/string/tree/main/lowercase

[@stdlib/string/next-grapheme-cluster-break]: https://github.com/stdlib-js/string/tree/main/next-grapheme-cluster-break

[@stdlib/string/num-grapheme-clusters]: https://github.com/stdlib-js/string/tree/main/num-grapheme-clusters

[@stdlib/string/pad]: https://github.com/stdlib-js/string/tree/main/pad

[@stdlib/string/pascalcase]: https://github.com/stdlib-js/string/tree/main/pascalcase

[@stdlib/string/percent-encode]: https://github.com/stdlib-js/string/tree/main/percent-encode

[@stdlib/string/prev-grapheme-cluster-break]: https://github.com/stdlib-js/string/tree/main/prev-grapheme-cluster-break

[@stdlib/string/remove-first]: https://github.com/stdlib-js/string/tree/main/remove-first

[@stdlib/string/remove-last]: https://github.com/stdlib-js/string/tree/main/remove-last

[@stdlib/string/remove-punctuation]: https://github.com/stdlib-js/string/tree/main/remove-punctuation

[@stdlib/string/remove-utf8-bom]: https://github.com/stdlib-js/string/tree/main/remove-utf8-bom

[@stdlib/string/remove-words]: https://github.com/stdlib-js/string/tree/main/remove-words

[@stdlib/string/repeat]: https://github.com/stdlib-js/string/tree/main/repeat

[@stdlib/string/replace]: https://github.com/stdlib-js/string/tree/main/replace

[@stdlib/string/reverse]: https://github.com/stdlib-js/string/tree/main/reverse

[@stdlib/string/right-pad]: https://github.com/stdlib-js/string/tree/main/right-pad

[@stdlib/string/right-trim-n]: https://github.com/stdlib-js/string/tree/main/right-trim-n

[@stdlib/string/right-trim]: https://github.com/stdlib-js/string/tree/main/right-trim

[@stdlib/string/snakecase]: https://github.com/stdlib-js/string/tree/main/snakecase

[@stdlib/string/split-grapheme-clusters]: https://github.com/stdlib-js/string/tree/main/split-grapheme-clusters

[@stdlib/string/startcase]: https://github.com/stdlib-js/string/tree/main/startcase

[@stdlib/string/starts-with]: https://github.com/stdlib-js/string/tree/main/starts-with

[@stdlib/string/substring-after-last]: https://github.com/stdlib-js/string/tree/main/substring-after-last

[@stdlib/string/substring-after]: https://github.com/stdlib-js/string/tree/main/substring-after

[@stdlib/string/substring-before-last]: https://github.com/stdlib-js/string/tree/main/substring-before-last

[@stdlib/string/substring-before]: https://github.com/stdlib-js/string/tree/main/substring-before

[@stdlib/string/trim]: https://github.com/stdlib-js/string/tree/main/trim

[@stdlib/string/truncate-middle]: https://github.com/stdlib-js/string/tree/main/truncate-middle

[@stdlib/string/truncate]: https://github.com/stdlib-js/string/tree/main/truncate

[@stdlib/string/uncapitalize]: https://github.com/stdlib-js/string/tree/main/uncapitalize

[@stdlib/string/uppercase]: https://github.com/stdlib-js/string/tree/main/uppercase

[@stdlib/string/utf16-to-utf8-array]: https://github.com/stdlib-js/string/tree/main/utf16-to-utf8-array

