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

parent d8eff635
...@@ -230,26 +230,16 @@ class String ...@@ -230,26 +230,16 @@ class String
end end
end end
def _regexp(re, mid) # those two methods requires Regexp that is optional in mruby
if String === re
if Object.const_defined?(:Regexp)
return Regexp.new(re)
else
raise NotImplementedError, "String##{mid} needs Regexp class"
end
end
re
end
## ##
# ISO 15.2.10.5.3 # ISO 15.2.10.5.3
def =~(re) #def =~(re)
_regexp(re, :=~) =~ self # re =~ self
end #end
## ##
# ISO 15.2.10.5.27 # ISO 15.2.10.5.27
def match(re, &block) #def match(re, &block)
_regexp(re, :match).match(self, &block) # re.match(self, &block)
end #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