且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用 preg_replace PHP 删除文本中的域名

更新时间:2023-02-21 20:05:33

这样的事情应该对您有所帮助:

Something like this should help you:

/([wW]{3,3}\.|)[A-Za-z0-9]+?\.(se|com|ru)/

用你需要的代替最后一个 se|com|ru.虽然在这之后你会有这样的事情:

replace the last se|com|ru with what you need instead. Although after this you'll have something like this:

最大的新闻门户之一,里面有很多内容.几个搜索引擎喜欢 ,并将他们的爬虫发送到这个网站.这也删除了

One of the biggest news portals, have a lot of contents inside. Several search engine like , and send their crawler to this sites. This also removed

要删除开头的空格,您可以执行 trim($str) 和其他空格的正则表达式,看起来像 preg_replace('/\s+/', ' ', $str); 应该可以帮助你.

To remove the space in the start you could do trim($str) and for the other spaces a regex that looks something like preg_replace('/\s+/', ' ', $str); should help you.