If you are trying to just solve the problem, regexs are great. The advantages of the manual parser are mostly no start up time and the fact that you have functions to create abstractions. You do end up with more code to validate and maintain.
If you are trying to just solve the problem, regexs are great. The advantages of the manual parser are mostly no start up time and the fact that you have functions to create abstractions. You do end up with more code to validate and maintain.
yeah. i wish more people understood how regex works internally. I've seen code in production that recompiles a uuid matching regex each time the uuid is used, when we already had a custom uuid checker in the codebase haha
Yikes. It is far to easy to recompile the regexs over and over again. Fortunately, #RustLang 's linter, clippy, has a check for compiling regexs in a loop. Of course, it doesn't catch all of the cases.
I've thought about using #RustLang 's macros to compile the regex to a state machine at compile time. That would remove the startup time that makes it hard to use in very fast applications like #AdventOfCode where I'm trying to get the run time for all 25 days to less than a second.
I've heard of docs.rs/ctreg/latest... but never tried it myself