I am trying to remove whitespace and dot from hyperlinks all rules are working fine except its not removing dot from url. Here are few examples
<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);
In the last example RE should remove dot from url. Dot is optional so I wrote this rule (.)?