Ruby Regex:拒绝整个单词

Mik*_*ike 7 ruby regex

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

更确切地说,我想拒绝"打印<除了"所有">"以外的任何东西.几个例子:

print all - match
frokenfooster - no match
print all nomnom - no match
print bollocks - no match
print allpies - no match
Run Code Online (Sandbox Code Playgroud)

Bra*_*tie 12

你正在寻找一个负面的预测.(参考 使用前瞻和后视)

(?!exclude)
Run Code Online (Sandbox Code Playgroud)

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