Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/forbeslindesay/regexp
Regular Expression Parser in Pure JS
https://github.com/forbeslindesay/regexp
Last synced: 16 days ago
JSON representation
Regular Expression Parser in Pure JS
- Host: GitHub
- URL: https://github.com/forbeslindesay/regexp
- Owner: ForbesLindesay
- License: mit
- Created: 2013-07-21T02:43:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-02-24T19:30:41.000Z (over 7 years ago)
- Last Synced: 2024-05-02T00:08:05.903Z (7 months ago)
- Language: JavaScript
- Homepage: http://demos.forbeslindesay.co.uk/regexp/
- Size: 12.7 KB
- Stars: 28
- Watchers: 5
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# regexp
Regex parser based on descriptions in http://www.javascriptkit.com/javatutors/redev2.shtml
[![Build Status](https://img.shields.io/travis/ForbesLindesay/regexp/master.svg)](https://travis-ci.org/ForbesLindesay/regexp)
[![Dependency Status](https://img.shields.io/david/ForbesLindesay/regexp.svg)](https://david-dm.org/ForbesLindesay/regexp)
[![NPM version](https://img.shields.io/npm/v/regexp.svg)](https://www.npmjs.com/package/regexp)## Installation
npm install regexp
## Usage
```js
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:
```console
$ npm install
$ npm test
```This will also automatically compile `index.js`.
The key source files are `src/grammer.pegjs` which is compiled using [pegjs](http://pegjs.majda.cz/) and `src/index.js` which is a CommonJS module with a special additional pseudo `import` statement.
## License
MIT