したがって、私の問題は、同じコンテンツにiframe、画像タグなどが含まれていることです。それらはすべて、正しい形式に変換する正規表現の一致を持っています。
最後に残ったのは通常の URL です。iframe、img、またはその他のタグ内ではなく、単にリンクであるすべてのリンクを見つける正規表現が必要です。この場合に使用されるタグは、BB ではなく通常の HTML タグです。
現在、コンテンツ レンダリングの最後のパスとしてこのコードを取得しています。ただし、上記で行われた他のすべてのこと (iframe と img レンダリング) にも反応します。したがって、そこにある URL も交換します。
$output = preg_replace(array(
'%\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))%s'
), array(
'test'
), $output);
そして、私のコンテンツは次のようになります。
# dont want these to be touched
<iframe width="640" height="360" src="http://somedomain.com/but-still-its-a-link-to-somewhere/" frameborder="0"></iframe>
<img src="http://someotherdomain.com/here-is-a-img-url.jpg" border="0" />
# and only these converted
http://google.com
http://www.google.com
https://www2.google.com<br />
www.google.com
ご覧のとおり、リンクの最後にも何かがある場合があります。正規表現を機能させるために 1 日を費やした後、最後の作業<br />
は私にとって悪夢でした。