-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
For Advent of Code I found I needed a function I'm calling re-find-groups-seq:
(re-find-groups-seq #"(\d+) (red|green|blue)"
"5 red, 2 green, 1 blue")
=>
([{:match "5", :within "5 red", :start 0, :end 1} {:match "red", :within "5 red", :start 2, :end 5}]
[{:match "2", :within "2 green", :start 7, :end 8} {:match "green", :within "2 green", :start 9, :end 14}]
[{:match "1", :within "1 blue", :start 16, :end 17} {:match "blue", :within "1 blue", :start 18, :end 22}])
Essentially, it's re-seq, but on each match, you get a vector of maps, not strings; the maps identify where in the input string the pattern group matched.
So if there's interest, I'm quite happy to add docs and tests and submit as a PR.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels