Actions
Feature #11100
openPermit multiple captures with String[Regexp, ...]
Status:
Open
Assignee:
-
Target version:
-
Description
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 ornil
. - 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()
.
- Array argument looks a little "noisy"?
- 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
Updated by djberg96 (Daniel Berger) almost 9 years ago
I support allowing multiple captures. I think the [1,2] syntax is the most intuitive.
Updated by avit (Andrew Vit) almost 9 years ago
- File 11100-Multiple-captures-with-string-regexp-array.patch 11100-Multiple-captures-with-string-regexp-array.patch added
Fixed proposed patch and added tests
Actions
Like0
Like0Like0