开发者

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/
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜