Fork me on GitHub

in addition to the above good advice, I would bind the regexes to meaningful names in a let block or def. I would have suggested some names to bind but it's too hard figuring out what each step is meant to do.


also #()instead of named functions here is actively hostile to readers


since # and % so readily blend in with the regex syntax when skimming


java regexes (which is what #"" becomes) support in-line comments via a syntax switch, it's a judgment call whether using a feature most people don't know is worth it for the readability on the regex

Clojure 1.10.1
(cmd)user=> (def x-y-split
               #"(?x) x   # pattern must start with x
                      (.) # capture the item in the middle
                      y   # pattern must end with y")
(cmd)user=> (re-seq x-y-split "xayxby")
(["xay" "a"] ["xby" "b"])
personally I would argue that using regular expression already means you expect users to deal with features that are obscure and I find this style of re much easier to read

❤️ 1

to elaborate a bit more (?x) is a syntax switch, and it turns on two features that I care about here: ignoring whitespace and allowing # comments until end of line


finally - I should have linked this - the docs for "free spacing mode" which is what the syntax ?x enables is called

Lukas Domagala02:03:49

Thank you, that does help with the crazy regexes!