简体   繁体   中英

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)\\b/i

I know this returns true when it sees error, how do you say 'not' in this case? thanks!

使用正确的Ruby运算符:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM