What resources should one consult if one wanted to build a regex library from scratch? #1078
-
I'm curious if you have any particular resources you prefer as a reference. Someday I would love to build a regex library with first-class support for compile-time regex compilation, so I think this is a good opportunity for me to ask you this! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Russ Cox's article series was the single most important bit: https://swtch.com/~rsc/regexp/ Otherwise, the source code of the RE2 and Go regexp engines is something I've read quite a bit over the years. Note that this is pretty biased in favor of regex engines based on finite automata. This might not be a good path to go down if you want to write a backtracker, which is likely necessary in order to support things like look-around or backreferences. Also, if I were me from 10 years ago, I would have loved to have this (shameless plug): https://blog.burntsushi.net/regex-internals/. In particular, it gets into a lot more of the engineering details of the regex engine than I think Cox's articles get into. |
Beta Was this translation helpful? Give feedback.
Russ Cox's article series was the single most important bit: https://swtch.com/~rsc/regexp/
Otherwise, the source code of the RE2 and Go regexp engines is something I've read quite a bit over the years.
Note that this is pretty biased in favor of regex engines based on finite automata. This might not be a good path to go down if you want to write a backtracker, which is likely necessary in order to support things like look-around or backreferences.
Also, if I were me from 10 years ago, I would have loved to have this (shameless plug): https://blog.burntsushi.net/regex-internals/. In particular, it gets into a lot more of the engineering details of the regex engine than I think Cox's artic…