marcbllv / regex3000 Goto Github PK
View Code? Open in Web Editor NEWA simple regex parser written in Go
A simple regex parser written in Go
It's complex to extract runes one-by-one from a string, better convert the input regex to a slice of rune at first.
Replace string usage by []rune everywhere
Currently regexes with a bad format usually raise a segfault.
This must be avoided and errors should be handled in a clean way.
TBD
When runnning:
$ bin/regex3000 'I have [1-9]+ l?eg{1,2}s' 'I have 3 legs'
it outputs false
, expected true
.
There's an issue with the brackets, we need to plug the previous states (here previous states of letter g
) to the final ones.
Matching function currently return true/false + the rest of string that matches
It would be cleaner to return the match position (if match==true), and this would allow for further developments in an easier way (eg: matching the beginning / end of string)
All Match() function in inspectors should take as input:
And return:
Handle beginning and end of string with ^
& $
Set values for mustMatchBeginning and mustMatchEnd in Starting & Final inspectors
Handle special sets defined via a backslash:
\d \D
\s \S
\w \W
Investigate whether we could use the Go OOP style described here: https://www.toptal.com/go/golang-oop-tutorial
The State
class might be a good pick for refactoring: we're using StateType
as an attribute while in the aforementioned article the authors discourages such pattern in Go.
Write new implementation according to specs below
We cannot use "negative" sets using brackets and ^
, eg: `[^a-zA-Z].
Update brackets parsing function: if first char is ^
, then create an OppositeSetInspector instead of a SetInspector
The braces parsing is complex and not very clean to write.
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.