[PHP-users 1342] Re: URLのリンク変換について(正規表現)

Ryo Fujita php-users@php.gr.jp
Tue, 21 Aug 2001 21:40:00 +0900


りおです。

水沼寛喜さんが01.8.21 9:30 PMに書きました:
>例:(この場合はhttp://www.nifty.comないの物は_blankなしにしたい)
>http://headlines.yahoo.co.jp/hl
>
>
>http://www.nifty.com/~aaa/aaaa/aaa.html
>
>      ↓
>
><a href="http://headlines.yahoo.co.jp/hl"
>target="_blank">http://headlines.yahoo.co.jp/hl</a>
>
>
><a
>href="http://www.nifty.com/~aaa/aaaa/aaa.html">http://www.nifty.com/~aaa/aaa
>a/aaa.html</a>
>
>に置き換えたいのですが・・・

$nifty="http://www.nifty.com";
printf("<a href=\"%s\"%s>%s</a>", $URL, strpos($URL, $nifty) ? " target=\"_
blank\"": "", $URL);
って感じじゃないかと思いますが、どうでしょう?