Skip to content
Regular Expression Parser in Pure JS
JavaScript
Find file
Latest commit 89e8c72 Dec 23, 2015 @ForbesLindesay Update badges
Failed to load latest commit information.
src Remove an imagined syntax for "UpTo" Aug 7, 2013
test Fix parsing control character Aug 6, 2013
.gitignore Initial Code Jul 21, 2013
.npmignore Initial Code Jul 21, 2013
.travis.yml Initial Code Jul 21, 2013
LICENSE Initial Code Jul 21, 2013
package.json Release 1.0.0 Aug 7, 2013
readme.md Update badges Dec 23, 2015

readme.md

regexp

Regex parser based on descriptions in http://www.javascriptkit.com/javatutors/redev2.shtml

Build Status Dependency Status NPM version

Installation

npm install regexp

Usage

var regexp = require('regexp')
var res = regexp('[a-z]+')
assert.deepEqual(res, { type: 'match',
  offset: 0,
  text: '[a-z]+',
  body:
   [ { type: 'quantified',
       offset: 0,
       text: '[a-z]+',
       body:
        { type: 'charset',
          offset: 0,
          text: '[a-z]',
          invert: false,
          body:
           [ { type: 'range',
               offset: 1,
               text: 'a-z',
               start: 'a',
               end: 'z' } ] },
       quantifier:
        { type: 'quantifier',
          offset: 5,
          text: '+',
          min: 1,
          max: Infinity,
          greedy: true } } ] })

Contributing

To run tests:

$ npm install
$ npm test

This will also automatically compile index.js.

The key source files are src/grammer.pegjs which is compiled using pegjs and src/index.js which is a CommonJS module with a special additional pseudo import statement.

License

MIT

Something went wrong with that request. Please try again.