Issue #11100 has been updated by Andrew Vit.

File 11100-Multiple-captures-with-string-regexp-array.patch added

Fixed proposed patch and added tests

----------------------------------------
Feature #11100: Permit multiple captures with String[Regexp, ...]
https://bugs.ruby-lang.org/issues/11100#change-56581

* Author: D.E. Akers
* Status: Open
* Priority: Normal
* Assignee: 
----------------------------------------
I propose that if we are able to conveniently grab one capture with this method, we ought to be able to grab more than one. Still, there are some caveats worth considering:

* It should return an array, but every other `#[]` variant returns a string or `nil`.
* Should the argument be an array, or should the method be variadic?
  - Array argument looks a little "noisy"? `'123abc'[/(\d+)(\w+)/, [2, 1]]`
  - Variadic method requires intrusive modification of internal calls to `rb_str_subpat()`.
* Complementary `#[]=` would be crpytic, overly complex, and likely go unused, but not adding it would break the symmetry.

I realize this is essentially an outline of why not to implement this feature, but I figured I'd toss it out there for feedback. Thoughts?

---Files--------------------------------
string_slice_many_captures.patch (906 Bytes)
11100-Multiple-captures-with-string-regexp-array.patch (2.38 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>