3 ms·
I avoid regexes like the plague. I like PEGs as a replacement.
by stakhanov 4y ago
I avoid regexes like the plague. I like PEGs as a replacement.
- BiteCode_dev 4y agoUnfortunatly most stdlib don't have a peg module, and peg libs are complicated.
- wruza 4y agoWhat would PEG for an email address (like in the article) look like?
- stakhanov 4y agoSee [1,2,3] for some examples. [1] https://en.wikipedia.org/wiki/Parsing_expression_grammar https://en.wikipedia.org/wiki/Parsing_expression_grammar [2] http://www.inf.puc-rio.br/~roberto/lpeg/ http://www.inf.puc-rio.br/~roberto/lpeg/ [3] https://nim-lang.org/docs/pegs.html https://nim-lang.org/docs/pegs.html
- wruza 4y agoI’m aware of PEGs (lpeg specifically), but couldn’t find a real email parsing example myself, hence the question. Most examples on the internet are as cryptic and noisy as regex imo when it comes to pattern matching, so I thought maybe there are other implementations. I find PEGs useful for actual CFG parsing, but tbh can’t see why I would avoid regex in favor of it in this case.