@aegenet/belt-str-escape-regex
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

npm version

@aegenet/belt-str-escape-regex

Escape String RegExp

Fork of https://github.com/sindresorhus/escape-string-regexp/ (this project, unfortunately, does not work well with TypeScript)

💾 Installation

yarn add @aegenet/belt-str-escape-regex@^1.4.0
# or
npm i @aegenet/belt-str-escape-regex@^1.4.0

📝 Usage

import { escapeRegex } from '@aegenet/belt-str-escape-regex';

const result = escapeRegex('Hello');
// result = 'Hello'
const result = escapeRegex('Hell{o} [you]');
// result = 'Hell\{o\} \[you\]'
const result = escapeRegex('');
// result = ''
const result = escapeRegex(null);
// throw Error 'Invalid usage: argument provided is not a string.'
const result = escapeRegex(undefined);
// throw Error 'Invalid usage: argument provided is not a string.'

Readme

Keywords

Package Sidebar

Install

npm i @aegenet/belt-str-escape-regex

Weekly Downloads

4

Version

1.5.0

License

MIT

Unpacked Size

4.51 kB

Total Files

7

Last publish

Collaborators

  • agenet