What do you mean by an explicit parser? Regexps are basically grammars for finite automata (typically with some more features like lookahead etc). Haven't used parser generators in a while, but is there anything better for general use today?
Regexes at the command line are usually about writing a quick throwaway pipeline that you tweak into working once in a specific case. It doesn't have to be a correct or reliable implementation, it just has to get the job done correctly in this instance. Special cases you may have encountered but didn't can be ignored.
If you are doing sometime repeatedly, especially if it's automated, then yes, if possible you should write/adopt a real parser and add error handling and such.
ETA: A notable exception is file paths and similar. Regexes are a totally acceptable way to parse those (modulo issues like escaping user input).
The link provided is bad. (It was never good, so it's likely just a mistake on the author's part.) Googling for "rust regex library" will take you to the right place. https://docs.rs/regex/latest/regex/
What do you use instead of grep on the CLI? Or do you "trust regex" when using grep?
riedel|1 year ago
maxbond|1 year ago
If you are doing sometime repeatedly, especially if it's automated, then yes, if possible you should write/adopt a real parser and add error handling and such.
ETA: A notable exception is file paths and similar. Regexes are a totally acceptable way to parse those (modulo issues like escaping user input).
burntsushi|1 year ago
What do you use instead of grep on the CLI? Or do you "trust regex" when using grep?
PurelyApplied|1 year ago
unknown|1 year ago
[deleted]