我想从超链接中删除空白和点所有规则都工作正常,除非它不从网址中删除点。这里有几个例子:从超链接剥离空白和点
<a href=" http://www.example.com ">example site</a>
<a href=" http://www.example.com">example 2</a>
<a href="http://www.example.com.">final example</a>
$text = preg_replace('/<a href="([\s]+)?([^ "\']*)([\s]+)?(\.)?">([^<]*)<\/a>/', '<a href="\\2">\\5</a>', $text);
在最后一个例子中,RE应该从url中删除点。点是可选的,所以我写了这个规则(。)?
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags –