New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ultimate-string-replace

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ultimate-string-replace

JS module to improve string.prototype.replace

latest
Source
npmnpm
Version
2.3.0
Version published
Maintainers
1
Created
Source

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!

FAQs

Package last updated on 06 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts