We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
MatchData#named_captures
1 parent 5ad3c71 commit 94d9b67Copy full SHA for 94d9b67
spec/ruby/core/matchdata/named_captures_spec.rb
@@ -9,5 +9,9 @@
9
it 'prefers later captures' do
10
/\A(?<a>.)(?<b>.)(?<b>.)(?<a>.)\z/.match('0123').named_captures.should == { 'a' => '3', 'b' => '2' }
11
end
12
+
13
+ it 'returns the latest matched capture, even if a later one that does not match exists' do
14
+ /\A(?<a>.)(?<b>.)(?<b>.)(?<a>.)?\z/.match('012').named_captures.should == { 'a' => '0', 'b' => '2' }
15
+ end
16
17
0 commit comments