From 8d7e71615810b46d82c62bc96fd27aedbbd5ac88 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 23 Jul 2013 20:22:15 +0900 Subject: String `=~` and `match` to work with pluggable Regexp; close #1398 --- mrblib/string.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'mrblib/string.rb') 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 ## -- cgit v1.2.3