fork download
  1. <?php
  2. function hashtag($str){
  3. $regex = "/#([a-zA-Z0-9]+)/";
  4. $str = preg_replace($regex, '<a href="e.php?tag=\\1">\\0</a>', $str);
  5. return($str);
  6. }
  7.  
  8. $str = 'Robert De Niro won the #oscar.';
  9. echo hashtag($str);
  10.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Robert De Niro won the <a href="e.php?tag=oscar">#oscar</a>.