Skip to content

replace prefix

Subhajit Sahu edited this page May 5, 2020 · 1 revision

Replace prefix match in string with specified value.

const replacePrefix = require('@extra-string/replace-prefix');
// replacePrefix(<string>, <prefix>, <replaced value>)

replacePrefix('tinman', 'tin', 'gun');
// 'gunman'
replacePrefix('muscleman', 'cle', 'cled');
// 'muscleman' (not prefix)
replacePrefix('-1.6022e-19', '-', '');
// '1.6022e-19'

extra-string

Clone this wiki locally