Commit 16884b87 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2702 from takahashim/fix-string-match

fix infinite loop in String#match(arg) when arg is String
parents d405eb55 bcceeba0
......@@ -146,8 +146,17 @@ class String
##
# ISO 15.2.10.5.27
def match(re, &block)
if re.respond_to? :to_str
if Object.const_defined?(:Regexp)
r = Regexp.new(re)
r.match(self, &block)
else
raise NotImplementedError, "String#match needs Regexp class"
end
else
re.match(self, &block)
end
end
end
##
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment