Class: Regexp

Inherits:
Object show all
Defined in:
lib/mini_sanity/match.rb

Instance Method Summary collapse

Instance Method Details

#match!(str, pos = 0) ⇒ MatchData

Like Regexp#match, but raises an exception if the match fails.

Examples:

/^([^@]+)@(.+)$/.match!("[email protected]")  # === MatchData
/^([^@]+)@(.+)$/.match!("@user")             # raises exception

Parameters:

  • str (String)

    String to search

  • pos (Integer) (defaults to: 0)

    Position in str to search from

Returns:

  • (MatchData)

Raises:



53
54
55
# File 'lib/mini_sanity/match.rb', line 53

def match!(str, pos = 0)
  str.match!(self, pos)
end