elixir - Scan of groups using RegEx -


The return to the following code is not exactly what I expected:

  iex 12) & Gt; Regex.scan (% r / (? Groupname & gt; a) b (c) / g, "abcdabcd", capture :: group) [["a"], ["a"]]  

There are 2 groups, but only appear in a designated result. And the group name has also been completely ignored.

If I use name_capture, I get the following:

  iex (14) & gt; (Group name: "A"]  

P> OK, I think

  Regex.scan (% r / (  

should be

or

 with ["a", "c"], ["a", "c"]] # = & gt;  Include group name in [[group name: "a"], [group name: "a"]] # = & gt; result  

So my question is Why do I have to name the groups in Group Capture when using Reggae scan, so that they completely ignore Hey?

Such a name is : group is misleading. Not for groups, but only named because you can get the desired behavior by using Capture :: all_but_first . I will document this option soon.


Comments