$re = '/<script[\s\S]*?>((?![\s\S]*?script)[\s\S]*?google-analytics)/';
$str = ' <script src="js/min/test.min.js"></script>
<script>
$(\'#buttons\').share({
networks: [\'twitter\'],
});
</script>
<!--[if lt IE 9]>
<script src="js/plugins/html5shiv.js"></script>
<script src="js/plugins/selectivizr.js"></script>
<![endif]-->
<!-- location for site scripts -->
<div id="scripts">
<script>
(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\');
ga(\'create\', \'UA-55555-1\', \'auto\', \'tracker\');
ga(\'tracker.send\', \'pageview\');
</script></div> <!-- /#lpsite-scripts -->
<div id="lppage-scripts">
</div>
<script type="text/javascript" src="js/min/form-validation.min.js"></script>
<script>
(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,\'script\',\'//www.google-analytics.com/analytics.js\',\'ga\');
ga(\'create\', \'UA-55555-1\', \'auto\', \'tracker\');
ga(\'lptracker.send\', \'pageview\');
</script>
';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php