📝✏️string-replace-enhanced
A package to go further with string replace
string-replace-enhanced allow you to go futher with the command replace for string in javascript. You have two options, use the object and implement his settings or use the functions in a standalone way.
Installation
Using npm:
npm install -S string-replace-enhanced
... and then:
// or// orconst default: stringReplaceEnhanced =
In NodeJS:
const default : stringReplaceEnhanced = // or
In a browser:
Usage
There is two possibilities, use the object ou the separated functions.
Object
With the object it will be possible to reuse a preset configuration or use the default one.
// If an option is missing, it will be given a default valueconst options = after: '«' around: before: '!' '?' ':' ';' '»' regex: replacer: ' ' toReplace: ' '; // Create a new stringReplaceEnhanced objectconst sre = options; // Use its methods simply giving the string to work onconsole;// Hello world !
Functions
For the standalone functions you will need to specify every arguments
console// Hello world !
Options
Check the links below to have the up to date version:
name | type | default | description |
---|---|---|---|
after | ReadonlyArray or string | ['«'] |
Array of char in need of potential need of replacement after itself |
around | ReadonlyArray or string | [] |
Array of char in need of potential need of replacement around itself |
before | ReadonlyArray or string | ['!', '?', ':', ';', '»'] |
Array of char in need of potential need of replacement before itself |
regex | ReadonlyArray or RegExp | [] |
Array of regex, replace match by the replacer |
replacer | string | ' ' |
Replacer of matching toReplace |
toReplace | string | ' ' |
String to replace, in the function replace toReplace can be an array of string |
Properties and methods
To see more about the methods and properties you can access to the documentation here
Documentation
To see more about the functions or the configuration you can access it in the latest documentation here or one in the forked project:
npm i && npm run build:doc
The documentation will be available in the docs
file.