🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

quotemeta

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quotemeta

escape regular expression characters

0.0.0
latest
Source
npm
Version published
Weekly downloads
33K
1.81%
Maintainers
1
Weekly downloads
 
Created
Source

quotemeta

escape regular expression metacharacters

This module is like perl's quotemeta without the part about \Q...\E.

build status

browser support

example

var quotemeta = require('quotemeta');

var query = new RegExp('\\d ' + quotemeta('node.js'));
var filter = function (x) { return query.test(x) };

var xs = [
    '0 node^js y',
    '1 node_js x',
    '2 node.js 5',
    '3 beep z',
    'X node.js Y',
    '4 boop w'
];
console.dir(xs.filter(filter));

methods

var quotemeta = require('quotemeta')

var escaped = quotemeta(string)

Return string with metacharacters escaped with \s.

install

With npm do:

npm install quotemeta

license

MIT

Keywords

regex

FAQs

Package last updated on 30 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts