【问题标题】:Regex that matches string that starts with but does NOT include匹配以但不包括开头的字符串的正则表达式
【发布时间】:2021-04-22 22:54:12
【问题描述】:

我正在尝试构建一个匹配任何以“表单提交成功邮件”开头但不包含数字 306 的字符串的正则表达式

这是我目前得到的: /^(?i)(form 提交成功邮件(?!/(306))).*/gm

3 个示例字符串:

form submit success mail - 306 - how are you today
form submit success mail - 2019 - this is a test
form submit success mail - 675 - what the

查询应该匹配底部的 2 个字符串,而不是第一个。

https://regex101.com/ 中测试但似乎不起作用 - 任何帮助表示赞赏。

【问题讨论】:

  • 你需要(?i)^(form submit success mail)(?!\s*-\s*306).*
  • 感谢 Wiktor,效果很好

标签: regex


【解决方案1】:

你可以选择类似的东西

^form submit success mail(?!.*306).*$

【讨论】:

  • 感谢基思,这个建议也很有效。非常感谢。
猜你喜欢
  • 2015-02-26
  • 2015-12-11
  • 2014-08-15
  • 2011-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-09
  • 1970-01-01
相关资源
最近更新 更多