2.3.0 • Published 7 years ago

ultimate-string-replace v2.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

ultimate-string-replace

Build Status Code Coverage code style: prettier semantic-release dependencies Greenkeeper badge

NPM

Javascript library to allow to find and wrap matches in a string.

It's main purpose is to be used in filters of objects, so you can highlight matches.

If the string has accents, ultimate-string-replace will get rid of them and match anyway.

If the string to match has accents, it will only match exact matches (case-insensitive).

Install

npm i -S ultimate-string-replace

ultimate-string-replace is also published in bower

bower install ultimate-string-replace

Usage

import ultimateStringReplace from 'ultimate-string-replace';

const data = "Crème brûlée"
const response = ultimateStringReplace(data, "rème brûlée", {'wrap_preffix': "<b>", 'wrap_sufix': "</b>" })
// Result -> 'C<b>rème brûlée</b>';

Examples of matches

MatcherInputOutput
heHello hello<b>He</b>llo <b>he</b>llo
2312 341<b>2 3</b>4
rème brûléeCrème brûléeC<b>rème brûlée</b>
Víctor victor Victor<b>Ví</b>ctor victor Victor
viVíctor victor Victor<b>Ví</b>ctor <b>vi</b>ctor <b>Vi<b>ctor
Víctor victor Victor<b>Ví</b>ctor victor Victor
noVíctor victor Victorfalse
  • If you have doubts, check the tests.

Running the tests

npm run test

Build the application

npm run build

ultimate-string-replace is written as an ES6 module, but it also gets transpiled to ES5.

Contributing

PR Welcome!

2.3.0

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.5.3

7 years ago

1.0.0

7 years ago

1.0.1

7 years ago