rama_ritwik Posted August 18, 2015 Share Posted August 18, 2015 I need regular expression to remove script tag if script contains "www.example.com". Please help me to find this Ex: <script type=\"text/javascript\">window.NREUM||(NREUM={});NREUM.info={\"beacon\":\"bam.nr-data.net\"\"applicationID\":\"8016770\",\"queueTime\":0,\"applicationTime\":653,\"atts\":\"H0YEGgNNGUs=\",\"errorBeacon\":\"bam.nr-data.net\",\"agent\":\"www.example.com\"}</script> 3. <script type=\"text/javascript\">// <![CDATA[ window.NREUM||(NREUM={});NREUM.info={\"beacon\":\"bam.nr-data.net\",\"applicationID\":\"8016770\",\"queueTime\":0,\"applicationTime\":30,\"atts\":\"H0YEGgNNGUs=\",\"errorBeacon\":\"bam.nr-data.net\",\"agent\":\"www.example.com\"} // ]]></script> Quote Link to comment https://forums.phpfreaks.com/topic/297846-remove-script-tag-if-script-contains-wwwexamplecom/ Share on other sites More sharing options...
scootstah Posted August 18, 2015 Share Posted August 18, 2015 (edited) I don't have time to mess with it right now, but my approach would be to strpos() for "www.example.com" and then find the previous <script and next </script> strings from that position. You shouldn't even need regex for this. Edited August 18, 2015 by scootstah Quote Link to comment https://forums.phpfreaks.com/topic/297846-remove-script-tag-if-script-contains-wwwexamplecom/#findComment-1519177 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.