gpt4 book ai didi

ruby 正则表达式 : Rejecting whole words

转载 作者:数据小太阳 更新时间:2023-10-29 06:57:17 26 4
gpt4 key购买 nike

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

更准确地说,我想拒绝“print ”。几个例子:

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)

会取消模式中单词“exclude”的资格。

关于 ruby 正则表达式 : Rejecting whole words,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4879395/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com