Ruby Regex How to specify not to match
How do you say not to match in Ruby Regex
ex. you do not want to return true if it sees 'error'
/\b(error)\开发者_如何学Gob/i
I know this returns true when it sees error, how do you say 'not' in this case? thanks!
Use the proper Ruby operator:
/\b(error)\b/i !~ someText
I would do something like the following excuse the /error/ pattern not sure exactly what you want to match here
return true unless b =~ /error/
or
return true if b !~ /error/
精彩评论