Notorious Preying Mantis
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    quotemetapublic

    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('\\' + 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

    none

    install

    npm i quotemeta

    Downloadsweekly downloads

    3,803

    version

    0.0.0

    license

    none

    repository

    github.com

    last publish

    collaborators

    • avatar