fork(2) download
  1. <?php
  2.  
  3. $re = '/\(link\)(.*?)\(\/link\)/';
  4. $str = "(link)there is link1(/link), (link)there is link2(/link)";
  5. $subst = "<a href='$1'>$1</a>";
  6. $result = preg_replace($re, $subst, $str);
  7. echo $result;
Success #stdin #stdout 0.01s 52472KB
stdin
Standard input is empty
stdout
<a href='there is link1'>there is link1</a>, <a href='there is link2'>there is link2</a>