Skip to content

Latest commit

 

History

History
45 lines (29 loc) · 1.19 KB

explanation.md

File metadata and controls

45 lines (29 loc) · 1.19 KB

A brief expalanation of incr-regex

All avaliable regexp packages treat matching as single matching function, for example the javascript built-in regexp, you either matche the entire regexp or you fail. This package provides a more flexible approach will return one of 4 states

Status Description
DONE String matches completely
OK The regexp matches, but will accept more characters, for example a zip code may be 5 digits or 9 digits
PARTIAL The regexp matches the string so far but is incomplete, i.e. needs more characters
FAIL The string does not match the regexp

Example

using the zipcode exmple

Reg Expression : [0-9]{5}-[0-9]{4} :

String Status
"90" PARTIAL
"90210" OK
"90210-5" PARTIAL
"90210-5003" DONE
"90210-500A" FAIL

The Algorithm

This is a brief explanation of the algorithm. Suppose we have the following regexp [a-z][0-9]-[0-9]|cat|dog

we parse the regexp to create the following tree:


We process the the tree to get the following graph:

Next - show processing steps