Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
share
/
nodejs
/
escape-string-regexp
๐ค Upload
๐ New File
๐ New Folder
Close
Editing: index.js
'use strict'; module.exports = string => { if (typeof string !== 'string') { throw new TypeError('Expected a string'); } // Escape characters with special meaning either inside or outside character sets. // Use a simple backslash escape when itโs always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patternsโ stricter grammar. return string .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&') .replace(/-/g, '\\x2d'); };
Save
Cancel