JSPM

  • Created
  • Published
  • Downloads 1025679
  • Score
    100M100P100Q213695F

node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines.

Package Exports

  • re2

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (re2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-re2

Build status Dependencies devDependencies NPM version

node.js bindings for RE2: fast, safe alternative to backtracking regular expression engines. The trade-offs for speed: lack of backreferences and zero-width assertions. See below for more details.

RE2 object emulates standard RegExp, and supports folowing properties:

And following methods:

It can be created like RegExp:

Additionally it can be created from a regular expression new RE2(regexp):

var re1 = new RE2(/ab*/ig); // from RegExp object
var re2 = new RE2(re1);     // from RE2 object

How to install

Installation:

npm install re2

Backreferences

Unlike the standard RegExp, RE2 doesn't support backreferences, which are numbered references to previously matched groups, like so: \1, \2, and so on. Example of backrefrences:

/(cat|dog)\1/.test("catcat"); // true
/(cat|dog)\1/.test("dogdog"); // true
/(cat|dog)\1/.test("catdog"); // false
/(cat|dog)\1/.test("dogcat"); // false

If this kind of matching is essential for your application, you should use RegExp.

Release history

  • 0.9.0 the initial public release