special-escape
v0.1.1
Published
Escape special characters in a string
Downloads
6
Readme
special-escape
Escape special characters in a string
Installation
special-escape
is published at npmjs.com, and can be installed using npm
or yarn
.
$ npm install special-escape # npm
$ yarn add special-escape # yarn
import resolveWhen from 'special-escape'; // ES6+
const resolveWhen = require('special-escape'); // ES5
Usage
const specialChars = ['+', '-', '=', '>', '.', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '\\', '/',]
const escapedString = escapeChars('$2a$10$!NgGQwxmjy..4aQTdsOJw\\O7HUd6FfiFQ2e/2F6XJQh1PeZjWlEbmK', specialChars);
assert(escapedString, '$2a$10$\!NgGQwxmjy\.\.4aQTdsOJw\\O7HUd6FfiFQ2e\/2F6XJQh1PeZjWlEbmK');