I have a string in Clojure and I'd like to name and extract various parts of a match. The standard way to do this is:
(re-seq #"\d{3}-\d{4}" "My phone number is 000-1234")
;; returns ("000-1234")
However I want to be able to name and access just the matched parts.
Here's an example:
(def mystring "Find sqrt of 6 and the square of 2")
(def patterns '(#"sqrt of \d" #"square of \d"))
When I match on mystring with my list of patterns, I'd like a result to be something like of {:sqrt 6, :root 2}.
Update
I found a 3rd party package called https://github.com/rufoa/named-re that supported named groups, but I was hoping there was a solution within a core library.