fork(1) download
  1. <?php
  2. $good="http://www.google.com/";
  3. $bad="http://img.google.com/";
  4. $r="#(?i)((?:f|ht)tps?://((?!img|jpe?g|gif|png|bmp))(?:([-a-z0-9()@:%_+.~\#?&;/=,])(?2))+(?!(?3)))#";
  5. $rep="<a href=$1 target='_blank'><b>$1</b></a>";
  6. echo preg_replace($r,$rep,$good); echo "\n";
  7. echo preg_replace($r,$rep,$bad);
  8.  
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<a href=http://www.google.com/ target='_blank'><b>http://www.google.com/</b></a>
http://img.google.com/