regexp.escape
A robust ES3-compatible polyfill for the ES7 `RegExp.escape` proposal - see https://github.com/benjamingr/RexExp.escape/
Last updated 9 years ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install regexp.escape 
SYNC missed versions from official npm registry.

regexp.escape Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

A robust & optimized ES3-compatible polyfill for the RegExp.escape proposal for ECMAScript 7.

Use it to safely escape RegExp special tokens for use in new RegExp.

Use it as a standalone function, or call its shim method to install it as a polyfill.

Example

var escape = require('regexp.escape');
var assert = require('assert');

var str = 'hello. how are you?';
var regex = new RegExp(escape(str), 'g');
assert.equal(String(regex), '/hello\. how are you\?/g');

Tests

Simply clone the repo, npm install, and run npm test

Current Tags

  • 2.0.1                                ...           latest (4 months ago)

6 Versions

  • 2.0.1                                ...           4 months ago
  • 2.0.0 [deprecated]           ...           4 months ago
  • 1.1.0                                ...           5 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (4)
Dev Dependencies (10)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE