简体   繁体   English

特定的正则表达式模式可停止广告

[英]Specific regex pattern to stop advertisement

I'm using the php function preg_match() to check for a specific pattern. 我正在使用php函数preg_match()来检查特定模式。

I've gone through about 50 websites so far, and still haven't figured out how to do this specific pattern. 到目前为止,我已经浏览了大约50个网站,但仍未弄清楚如何执行此特定模式。

If there is the word "dot" or "d0t" after anything and before anything that contains "com" or "org", it would catch it. 如果在包含“ com”或“ org”的任何内容之后和之前存在单词“ dot”或“ d0t”,它将被捕获。

I'm making something that filters out advertisement, it separately filters out anything except for letters, numbers, and underscores; 我正在做的事情可以过滤掉广告,它可以分别过滤掉字母,数字和下划线以外的所有内容; that has to stay separate. 必须分开。 It has it's own purpose, and it's own output. 它有自己的目的,也有自己的输出。

If you can help me figure out how to do this, or link me to anything that I may have missed after 2 hours of googling, I would so greatly appreciate it. 如果您可以帮助我弄清楚该怎么做,或者将我链接到经过2个小时的谷歌搜索后可能会错过的任何事情,我将非常感谢。 Thanks. 谢谢。

问题不是很清楚,但是您可以为preg_match尝试使用此正则表达式:

'~d[0o]t.*?(?:com|org)~i'

This matches word "dot" or "d0t" before anything that contains "com" or "org"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM