Closed postmodern closed 1 year ago
Unfortunately, that error message isn't entirely helpful. We do support ranges, but only when both the start and end values are specified.
string = "aaaabababab"
regexp = /(ab)(ab)(ab)/
match = string.match(regexp)
p match[1..3] # => ["ab", "ab", "ab"]
There's nothing in the Ruby Spec Suite for this, so it's likely an oversight. We'll fix the issue, but if that's a blocker, you can avoid it by specifying the end value in the range, providing you have it.
As a note, there is MatchData#captures
for this exact pattern (from https://github.com/ronin-rb/ronin-vulns/commit/b7f472e527619f6fab70e8a44d0895f8904214a9#r86454351)
Thank you for report. Fixed in b7d7cd0890896672c587bbb9277b00f7bb468c70.
It does not appear that
MatchData#[]
supports accepting an unbounded range of indices.Steps To Reproduce
Expected Result
Actual Result
Version Information