我有这一行来阻止广告主机名,例如 ad.somedomain.tld 但它似乎阻止了下载,上传等主机名。
([\w.-]+\.)?ad\.[^/]+/?
什么是正确的语法,谢谢
答案 0 :(得分:2)
<强>正则表达式强>
\b(?:.?)ad(?:.?)\b
<强> 描述 强>
\b Word boundary: match in between (^\w|\w$|\W\w|\w\W)
(?:.?) Non-capturing Group
. 0 to 1 times [greedy] Any character (except newline)
ad Literal ad
(?:.?) Non-capturing Group
. 0 to 1 times [greedy] Any character (except newline)
\b Word boundary: match in between (^\w|\w$|\W\w|\w\W)
可视化 (由debuggex提供)