Ruby Regex:拒绝整个单词

我知道在 Regex中,你可以拒绝符号列表,例如[^ abc].在我输入的中间看到一个完整的单词时,我想拒绝.

更确切地说,我想拒绝“print<除了”all“>”之外的任何东西.
几个例子:

print all - match
frokenfooster - no match
print all nomnom - no match
print bollocks - no match
print allpies - no match

解决方法

你正在寻找 negative look-ahead.(参考文献 using look-ahead and look-behind)
(?!exclude)

会取消模式中“排除”一词的资格.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...