大网数据广告活动
服务器运维问答

Postfix error in regexp in body checks expression

· 52CE 我爱测

Emails containing: blablabla.icu/blabla should be blocked. I get confused with this rule to block and emails that contain a link which address finish with .icu/: /.*\.icu\/*./ Reject The problem is that any emails, including atta…

问题原文

原帖链接 · Kaf · CC BY-SA 4.0

Emails containing: blablabla.icu/blabla should be blocked. I get confused with this rule to block and emails that contain a link which address finish with .icu/:

/.*\.icu\/*./ Reject 

The problem is that any emails, including attachments, that contains anything.icuabacadada are also blocked.

It seems the second \ before the / is not working as intent. Any suggestions how to fix this?

已采纳解答

原帖链接 · asdmin · CC BY-SA 4.0

Let me just take the regex out of your question:

/.*\.icu\/*./
 ^^                  (A) this part is not needed
   ^^^^^             (B) this matches .icu
        ^^^          (C) this matches 0, 1, 2 or any number of /
           ^         (D) this matches 1 character (any of them)

To get to the proper regex, you need to

  • remove A (to improve performance)
  • keep B
  • modify C to describe one / character
  • drop D (I presume it was placed here by a mistake, perhaps you mixed .* to *.?

So the proper regexp is:

/\.icu\//

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。