【问题标题】:Filter strings that do not contain one of the following strings过滤不包含以下字符串之一的字符串
【发布时间】:2016-08-16 11:43:06
【问题描述】:

我想过滤不包含以下字符串之一的字符串

ABCD
IJKL

我尝试使用 regex101 创建正则表达式

https://regex101.com/r/gI6sN8/1

这里有什么问题?

也尝试了Regex for string not containing multiple specific words的答案

但它没有用 https://regex101.com/r/gI6sN8/3

【问题讨论】:

标签: regex


【解决方案1】:

我想你正在寻找这样的东西?

https://regex101.com/r/gI6sN8/10

(?=ABCD|IJKL)(.*)
(?= // This is a look ahead
ABCD|IJKL // ABCD or IJKL
) // Close the look ahead

(.*) // Get EVERYTHING if the line contains the look ahead and return me that line

但是你的问题有点不清楚。如果您可以整理并给出更清晰的描述,我相信我们将能够为您提供更多帮助。

【讨论】:

  • 该短语在每个字符串中包含子字符串字符串之一时查找。我正在寻找何时不包含子字符串。
  • 如果你能使用 GREP,使用 -v 来反转你的匹配。否则,消极看待背后可能是您最好的方法。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-05
  • 2012-03-07
  • 1970-01-01
  • 2018-09-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多