Skip to content

Commit eb71e5a

Browse files
committed
Add new ruby specs for regular expressions
1 parent b6c91ec commit eb71e5a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/ruby/language/regexp/repetition_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,15 @@
128128
RUBY
129129
end
130130
end
131+
132+
it "treats ? after {n} quantifier as another quantifier, not as non-greedy marker" do
133+
/a{2}?/.match("").to_a.should == [""]
134+
end
135+
136+
it "matches zero-width capture groups in optional iterations of loops" do
137+
/()?/.match("").to_a.should == ["", ""]
138+
/(a*)?/.match("").to_a.should == ["", ""]
139+
/(a*)*/.match("").to_a.should == ["", ""]
140+
/(?:a|()){500,1000}/.match("a" * 500).to_a.should == ["a" * 500, ""]
141+
end
131142
end

0 commit comments

Comments
 (0)