trim-character

2.0.1 • Public • Published

trim-character Build Status

Trim characters from the string.

Install

npm install --save trim-character

Example

Simple example

var trim = require('trim-character');
trim(',foo,bar,', ','); // foo,bar
trim(',,,,,foo,bar,,,,,', ','); // foo,bar
trim('foofoobarfoofoo', 'foo'); // bar

Case insensitive replace

trim('fooFOObarFOOfoo', 'foo', 'i'); // bar

Trim just from left or right

trim.left(',foo,bar,', ','); // foo,bar,
trim.right(',foo,bar,', ','); // ,foo,bar

Api

String

Type: String
Default: undefined

String to be trimmed.

Characters

Type: String
Default: undefined

Characters to trim.

RegExp flags (optional)

Type: String
Default: 'g'

Regexp flags, g is always appended even if you dont specify it in your parameter.

License

MIT © Daniel Husar

Package Sidebar

Install

npm i trim-character

Weekly Downloads

198

Version

2.0.1

License

MIT

Last publish

Collaborators

  • efrafa