From: eregontp@... Date: 2018-04-08T11:11:06+00:00 Subject: [ruby-core:86478] [Ruby trunk Feature#14669] Regexp does not expose the amount of capture groups. Issue #14669 has been updated by Eregon (Benoit Daloze). This information is available for named captures via Regexp#names and Regexp#named_captures, but it doesn't seem available for unnamed capture groups: ~~~ruby [15] pry(main)> /(?a)(?b)(?c)/.named_captures => {"one"=>[1], "two"=>[2], "three"=>[3]} [16] pry(main)> /(a)(b)(c)/.named_captures => {} [17] pry(main)> /(?a)(?b)(?c)/.names => ["one", "two", "three"] [18] pry(main)> /(a)(b)(c)/.names => [] ~~~ ---------------------------------------- Feature #14669: Regexp does not expose the amount of capture groups. https://bugs.ruby-lang.org/issues/14669#change-71417 * Author: xfbs (Patrick Elsen) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- For a project we needed to know how many capture groups a Regex exposes (before actually matching it). The Onigmo regex library used by Ruby has this information, accessible with *onig_number_of_captures(const regex_t \*)*, but the Ruby Regexp class doesn't expose this information. -- https://bugs.ruby-lang.org/ Unsubscribe: