Skip to content

deniskyashif/regexjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

regexjs

Build Status

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 for the complete implementation details.

Example

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