$str :: のような文字列があるとしましょう
$str = "Test,
Here\'s an interesting in-house litigation position with JPMorgan Chase in New York I thought you might be interested inL
<a href="http://www.example.com/lcdetail.php?akey=e1725">http://www.example.com/lcdetail.php?akey=e1725</a>
They are not using recruiters to fill this job, so if you are interested you can just apply directly.
http://www.example.com/lcdetail.php?akey=e1725
Cordially
--Harrison";
タグが存在しないリンクにタグを追加したいと思います。
この関数を使用しましたが、目的の値が返されませんでした。
function processString($s){
return preg_replace('@(?<!href=")(https?:\/\/[\w\-\.!~?&=+\*\'(),\/]+)((?!\<\/\a\>).)*@i','<a href="$1">$1</a>',$s);
}
私の要件は、アンカータグが存在する場合はリンクに追加し、存在しないものには追加しないことです。
ありがとう。