Remove String#=~ and String#match that requires Regexp.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2019-05-15 09:55:21 +09:00
parent d8eff635fd
commit fd37bc53de
+7 -17
View File
@@ -230,26 +230,16 @@ class String
end
end
def _regexp(re, mid)
if String === re
if Object.const_defined?(:Regexp)
return Regexp.new(re)
else
raise NotImplementedError, "String##{mid} needs Regexp class"
end
end
re
end
# those two methods requires Regexp that is optional in mruby
##
# ISO 15.2.10.5.3
def =~(re)
_regexp(re, :=~) =~ self
end
#def =~(re)
# re =~ self
#end
##
# ISO 15.2.10.5.27
def match(re, &block)
_regexp(re, :match).match(self, &block)
end
#def match(re, &block)
# re.match(self, &block)
#end
end