Class: Regexp
Instance Method Summary collapse
-
#match!(str, pos = 0) ⇒ MatchData
Like Regexp#match, but raises an exception if the match fails.
Instance Method Details
#match!(str, pos = 0) ⇒ MatchData
Like Regexp#match, but raises an exception if the match fails.
17 18 19 20 21 22 23 24 25 |
# File 'lib/mini_sanity/util/regexp.rb', line 17 def match!(str, pos = 0) result = self.match(str, pos) if result.nil? raise MiniSanity::Error.new(nil, "String matching #{self.inspect}#{" from position #{pos}" if pos != 0}", str.inspect) end result end |