UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

12 lines (11 loc) 406 B
/** * Escapes characters from the given string so that it can be used within a RegExp without being * parsed as RegExp syntax. * * @category RegExp * @category Package : @augment-vir/common * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export function escapeStringForRegExp(input) { return input.replaceAll(/[\^$\\.*+?()[\]{}|]/g, String.raw `\$&`); }