fork(46) download
  1. <?php
  2.  
  3. $txt = '
  4. <div></div>
  5. <script params...>text1</script>
  6. <style params...>text2</style>
  7. <p params...>text3</p>';
  8.  
  9. print preg_replace('/(<(script|style)\b[^>]*>).*?(<\/\2>)/s', "$1$3", $txt);
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
 <div></div>
 <script params...></script>
 <style params...></style>
 <p params...>text3</p>