fork download
  1. <?php
  2.  
  3. $str = '
  4. akwlhfwhfqwfh[2]
  5. erhreherhreh
  6. dsgdsgsdg[q]
  7. ';
  8.  
  9. $patterns = [
  10. '/(.*)\[2\]/',
  11. '/(.*)\[q\]/',
  12. ];
  13. $replaces = [
  14. '<h2>$1</h2>',
  15. '<quote>$1</quote>',
  16. ];
  17. echo preg_replace($patterns, $replaces, $str);
Success #stdin #stdout 0s 82944KB
stdin
Standard input is empty
stdout
<h2>akwlhfwhfqwfh</h2>
erhreherhreh
<quote>dsgdsgsdg</quote>