summaryrefslogtreecommitdiffhomepage
path: root/mrblib/string.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-07-23 20:22:15 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-07-23 20:22:15 +0900
commit8d7e71615810b46d82c62bc96fd27aedbbd5ac88 (patch)
treed8293b34938e386d32a9c0c29a0ee3259438067d /mrblib/string.rb
parent84991d63886fa75c7c9ba82712e12b0537b2313a (diff)
downloadmruby-8d7e71615810b46d82c62bc96fd27aedbbd5ac88.tar.gz
mruby-8d7e71615810b46d82c62bc96fd27aedbbd5ac88.zip
String `=~` and `match` to work with pluggable Regexp; close #1398
Diffstat (limited to 'mrblib/string.rb')
-rw-r--r--mrblib/string.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/mrblib/string.rb b/mrblib/string.rb
index 131d30446..49f87be8b 100644
--- a/mrblib/string.rb
+++ b/mrblib/string.rb
@@ -133,6 +133,18 @@ class String
a = self[pos+1..-1]
self.replace([b, value, a].join(''))
end
+
+ ##
+ # ISO 15.2.10.5.5
+ def =~(re)
+ re =~ self
+ end
+
+ ##
+ # ISO 15.2.10.5.27
+ def match(re, &block)
+ re.match(self, &block)
+ end
end
##