I see a long code file filled with comments and long paragraph-level explanations. I think I’d rather just learn and use regex.
I see a long code file filled with comments and long paragraph-level explanations. I think I’d rather just learn and use regex.
For your average haskell programmer you could drop all of those comments since the code isn't really doing anything that couldn't be determined by just reading it.
Regexes are effectively write-only. If you change the grammar parsed by a regex, you're probably going to discard the regex and make a new one.
// STRing: matches anything inside quotes (single or double)
#define STR "[\"'](.*)[\"']"
// NUMber: matches decimal or hexadecimal numbers
#define NUM "([[:digit:]]x?[[:xdigit:]]*)"
regcomp(®_exp, STR NUM , REG_EXTENDED | REG_ICASE);
So at the end I compose the RE with the various parts, which are documented separately.Of course regular expressions are really more of a category of expressions, and the traditional kleene star notation is only one of many options; regular expressions do not somehow inherently need to use that specific syntax.
Pomsky and VerbalExpressions are just some examples of alternative syntaxes for regex. Apparently there is even a port of VerbalExpressions for Haskell:
https://github.com/VerbalExpressions/HaskellVerbalExpression...
[1]: <https://github.com/VerbalExpressions/JSVerbalExpressions/tre...>