fork(1) download
  1. <?php
  2.  
  3. $re = '/(\w+)/u';
  4. $str = 'Катя, Валя, Таня, Настя';
  5. $subst = '<a href=\"$1\">$1</a>';
  6.  
  7. echo preg_replace($re, $subst, $str);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
<a href=\"Катя\">Катя</a>, <a href=\"Валя\">Валя</a>, <a href=\"Таня\">Таня</a>, <a href=\"Настя\">Настя</a>