coltnz
1
Hi, I’d love some feedback on the usefulness of this:
(re/and #"a" #"b")
=> #"(ab)"
(re/or #"a" (re-pattern "b"))
=> #"(a|b)a"
(re/or #"a" (re/and #"b"))
=> #"(a|(b))"
(def def-re #"bc")
(let [local-re #"ef"]
(re/or def-re local-re))
=> #"(bcd|bcd)"
cheers
Colin
2 Likes
Is the purpose of this to make regex more readable?
plexus
3
I like it! I imagine this can be pretty handy sometimes.
It also reminds me a bit of Emacs’s rx
macro
coltnz
4
Yep also allows re-use and is particularly handy for clojure.spec.
DjebbZ
5
Reminds me of https://www.npmjs.com/package/verbal-expressions. It may exist in other languages (Ruby, Java ?). May be a source of inspiration.