fork(1) download
  1. <?php
  2.  
  3. //search to replace
  4. $text = '[b]this will be bold[/b] but this will be not.';
  5. $search = array('~\[([^]]+)\]([^][]*)\[/\1\]~');
  6. //replace with
  7. $replace = array('<$1>$2</$1>');
  8. echo preg_replace($search, $replace, $text);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
<b>this will be bold</b> but this will be not.