Skip to content

Proposal: re-find-groups-seq #84

@hlship

Description

@hlship

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions