fork download
  1. <?php
  2.  
  3. $string = "
  4. <head>
  5. <script>
  6. $(document).ready(function(){
  7. $('.x').click(function(){
  8. // some thing
  9. });
  10. $('.y').click(function(){
  11. // some thing
  12. });
  13. });
  14. </script>
  15. </head>
  16. ";
  17.  
  18. preg_match_all('~\$\((?!document\).ready).*?\}\);~sim', $string, $matches);
  19.  
  20. print_r($matches[0]);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Array
(
    [0] => $('.x').click(function(){
        // some thing
    });
    [1] => $('.y').click(function(){
        // some thing
    });
)