1.0.2 • Published 2 years ago

smart-replace v1.0.2

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

smart-replace

Searches a string by regex and lets you replace every occurrence by executing a matcher function.

Usage

import { smartReplace } from 'smart-replace';

const oldStr = 'Among us sus1 sus2 sus3 sus4';
const regex = /sus[0-9]+/g;
const newStr = await smartReplace(oldStr, regex, async (match) => {
    return "sussy!";
});

console.log(newStr); // Among us sussy! sussy! sussy! sussy!