https://github.com/deniskyashif/regexjs
A fast and minimal regular expression engine.
https://github.com/deniskyashif/regexjs
finite-state-machine javascript regular-expression
Last synced: about 2 months ago
JSON representation
A fast and minimal regular expression engine.
- Host: GitHub
- URL: https://github.com/deniskyashif/regexjs
- Owner: deniskyashif
- Created: 2019-02-14T22:47:25.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-01T07:55:39.000Z (about 2 years ago)
- Last Synced: 2024-04-14T12:59:01.787Z (almost 2 years ago)
- Topics: finite-state-machine, javascript, regular-expression
- Language: JavaScript
- Homepage: https://deniskyashif.com/implementing-a-regular-expression-engine/
- Size: 983 KB
- Stars: 72
- Watchers: 5
- Forks: 17
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# regexjs
[](https://github.com/deniskyashif/ssfst/actions?query=workflow%3A%22Node+CI%22)
A regular expression engine implementation in JavaScript. It supports concatenation, union (|), zero-or-more (\*), one-or-more (+), and zero-or-one (?) operations as well as grouping. It follows Ken Thompson's algorithm for constructing an NFA from a regular expression.
Check out my [blog post](https://deniskyashif.com/2019/02/17/implementing-a-regular-expression-engine/) for the complete implementation details.
### Example
```javascript
const { createMatcher } = require('./regex');
const match = createMatcher('(a|b)*c');
match('ac'); // true
match('abc'); // true
match('aabababbbc'); // true
match('aaaab'); // false
```
### Try It
```
git clone https://github.com/deniskyashif/regexjs.git
cd regexjs
npm i
npm start
```
### Run the tests
`npm t`