Link to home
Start Free TrialLog in
Avatar of Valleriani
VallerianiFlag for Sweden

asked on

PHP and REGEXP: Remove a specific line that has a certain javascript file in it.

Apparently when using AVG (Antivirus) it likes to add coding in WYSIWYG such as CKEDITOR. Most help has been to 'disable' AVG, but this doesn't suite me for my website. I'd prefer the coding be removed if it was there on save. I already have PHP processing after clicking save, I just don't know how to do this portion because it can be slightly random, but the javascript file seems to always be the same:

This is the line that gets added:
<script src="/A2EB891D63C8/avg_ls_dom.js" type="text/javascript"></script>

The thing is, the 'A2EB891D63C8' can be random from what I see. The script is always avg_ls_dom.s, and it has a starting <script and ending </script> right after it. It's a bit above what I know of, since I only know regexp in basic terms (Like removing all but a-z0-9/etc.)

Any suggestions here? I just simply want to remove it every time in a preg_replace (I believe that's what it would use.)

Thank you very much!

SOLUTION
Avatar of Derokorian
Derokorian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Interestingly no matter how many script tags i put on the test data, it only removes the one he specifically asked to be removed. Of course, could just use a negate instead of a dot.
$pattern = "#<script[^>]*avg_ls_dom.js[^>]*></script>#i";
It does work, but then again all of your <script> tags are on different lines I would bet (and you are not using single-line mode). If you put them on one single line, then you would see a different result.