@extra-regexp/escape.min

Escapes string for use in RegExp.

Usage no npm install needed!

<script type="module">
  import extraRegexpEscapeMin from 'https://cdn.skypack.dev/@extra-regexp/escape.min';
</script>

README

Escapes string for use in RegExp.

This is part of package extra-regexp.

This is browserified, minified version of @extra-regexp/escape.
It is exported as global variable regexp_escape.
CDN: unpkg, jsDelivr.

require('extra-regexp');

RegExp.escape('break. fix.');
// 'break\\. fix\\.'
/* note : double backslashes represent a single backslash */

RegExp.escape('(*.*)');
// '\\(\\*\\.\\*\\)'

RegExp.escape('\\d \\D (?:)');
// '\\\\d \\\\D \\(\\?:\\)'


reference

RegExp.escape(string);
// string: string to escape
// return -> string 'escaped string'


references