Skip to content

Commit e2cfb6a

Browse files
committed
Add Ruby spec for regex backreferences to unmatched groups
1 parent f8fdbe7 commit e2cfb6a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

spec/ruby/language/regexp/back-references_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
(/\10()()()()()()()()()()/ =~ "\x08").should == 0
6464
end
6565

66+
it "fails when trying to match a backreference to an unmatched capture group" do
67+
/\1()/.match("").should == nil
68+
/(?:(a)|b)\1/.match("b").should == nil
69+
end
70+
6671
it "ignores backreferences > 1000" do
6772
/\99999/.match("99999")[0].should == "99999"
6873
end

0 commit comments

Comments
 (0)