liubruce / regexjs

A fast and minimal regular expression engine.

Home Page:https://deniskyashif.com/implementing-a-regular-expression-engine/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

regexjs

Build Status

This is a good regular expression engine. I refer this to finish my course work.

I added the wildcard feature using the char "." but I removed one-or-more (+), and zero-or-one (?).

Other functions are simliar the original one. Sorry, I didn't finish the test function. Please don't use it.

The detail is below:


A regular expression engine implementation in JavaScript. It supports concatenation, union (|), wildcards(.), zero-or-more (*), operations as well as grouping. It follows Ken Thompson's algorithm for constructing an NFA from a regular expression.

Check out denis's 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

### Example2

const { createMatcher } = require('./regex');
const match = createMatcher('a.');

match('ab'); // true
match('ac'); // true



### Try It

git clone https://github.com/liubruce/regexjs.git
cd regexjs
npm i
npm start

About

A fast and minimal regular expression engine.

https://deniskyashif.com/implementing-a-regular-expression-engine/


Languages

Language:JavaScript 100.0%