nitely / nregex Goto Github PK
View Code? Open in Web Editor NEWA fast DFA based Regex engine that supports submatches
Home Page: https://nitely.github.io/nregex/
License: MIT License
A fast DFA based Regex engine that supports submatches
Home Page: https://nitely.github.io/nregex/
License: MIT License
Find is always greedy even when non-greedy is specified i.e: a.*?b
. This was fixed in nim-regex (nitely/nim-regex#62) which now shares a similar algorithm for the NFA. A very similar fix can be implemented for nregex.
Regex similar to ($|^)\w+
will always return false. Regex similar to ($*)*\w+
won't return an empty capture (or won't always return the right result, I don't remember anymore). This was fixed in nim-regex, see nitely/nim-regex#79 and nitely/nim-regex#84
nim-regex implements a literals optimization that puts it on par with PCRE performance. This is only because the nim-regex NFA engine is pretty slow, as it's is 35x times faster than PCRE in one of the benchmarks where the NFA is not hit much. I think, nregex would be consistently faster than PCRE once the optimization is in place.
However, both find/findAll APIs have quadratic time worst case complexity (linear time best case, though). Granted, PCRE has the same issue in the same situations (and many more). A linear time version would require to track all possible matching states in parallel (NFA style), and it would be slower. Another way may be to transform the expression into re".*regex"
where "regex" is the expression, and "dot" matches new lines, that way the regex can start anywhere in the string.
That said, nregex is just a PoC to play around DFAs, so I doubt I'll ever implement this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.