fork download
  1. <?php
  2.  
  3. $re = "/\[(.*)\|(.*)\]/";
  4. $str = "wwetwetw[id1|Павел Дуров]twtweyweywy";
  5. $subst = '<a href="http://content-available-to-author-only.com/$1" target="_blank">$2</a>';
  6.  
  7. $result = preg_replace($re, $subst, $str);
  8. echo $result;
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
wwetwetw<a href="http://content-available-to-author-only.com/id1" target="_blank">Павел Дуров</a>twtweyweywy