Negative lookbehind on html comments with PHP for script extraction -


I have a problem with IE comment in HTML, I am trying to parse the scripts from an HTML string, which Not very difficult but, in my regular expression, I am commenting on script to IE, and in fact it does not want to.

Currently my script is:

  function get_scripts ($ Html) {preg_match_all ('# & lt; script (. *?) & Lt; / script & gt; ; #is', $ html, $ matches); $ Script = ""; If (isset ($ matches [0]) and is_array ($ matches [0])) {foreach ($ matches = $ as $ key = & gt; $ value) {$ scripts $ $ Value; }} Return $ script; } $ Html = '& lt ;! - [If LT IE 9] & gt; & Lt; Script src = "// html5shim.googlecode.com/svn/trunk/html5.js"></script> & Lt; [Endif] - & gt; & Lt; Script type = "text / javascript" & gt; Var domain_blog_json = ""; & Lt; / Script & gt; '; Echo get_scripts ($ html);  

Does anyone have to achieve this? I have tried to look negative, but it does not work, or I am definitely in the reggae app.

Thank you!

   

Try it out. Hold the possession. It will only give scripts from the non-commented section.


Comments