mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Remove String#=~ and String#match that requires Regexp.
This commit is contained in:
+7
-17
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user