match(expected)public
Given a Regexp or String, passes if actual.match(pattern)
Examples
email.should match(/^([^\s]+)((?:[-a-z0-9]+\.)+[a-z]{2,})$/i) email.should match("@example.com")
2Notes
Careful when comparing strings
Input String is treated as Regexp:
"*test*".should match "*test*" #=> fail
"*test*".should match ".*test.*" #=> pass
Regexp special characters inside input String can't [be] escaped:
"test".should match "\test\" #=> fail "test".should match /\test\/ #=> pass
Input strings are treated as regexp
Input strings are treated as regexp, but you can escape special regexp characters as usual:
"test".should match "\\test\\" #=> pass "test".should match '\test\' #=> pass "test".should match /\test\/ #=> pass