As it randomly came up on Slack today, I might as well announce a small new package here: ReadableRegex.jl https://github.com/jkrumbiegel/ReadableRegex.jl
The point of it is to be able to construct regular expressions in a verbose but easy to understand way, as the functions read almost like a natural sentence. This pays off over time as complex expressions stay easy to comprehend for people reading the source code. Normally, sufficiently complex regexes tend to be treated a bit like “magic” and nobody wants to touch them again if they seem to work.
Here’s an example from the readme. Can you quickly determine, what this regex does?
regex = r"[\+-]?(?:\d*\.)?\d+"
Now try this, without knowing the ReadableRegex syntax:
regex = maybe(["-", "+"]) * maybe(one_or_more(DIGIT) * ".") * at_least_one(DIGIT)
They do the same thing of course, which is matching different floating point numbers. Now imagine adding support for exponential syntax to the first one, for the second one it wouldn’t be that hard. It’s just difficult for humans to parse a sequential string representing nested expressions, obscured through abbreviations and lots of backslashes.
You can install it via ]add ReadableRegex. All docs are in the readme file.