|
-
Apr 5th, 2001, 09:23 AM
#1
Thread Starter
Member
I have a html page like this
Code:
<script language="vbscript">
some script
</script>
Some text
<script language="vbscript">
some more script
</script>
Some more text
I want to remove the scripts so i used the following code:
Code:
$open = fopen("file.html", "r");
$read = fread($open, 20000);
fclose($open);
$read = eregi_replace("<script>(.*)</script>", "" , $read);
what it outputs is just Some more text. The scripts are gone but along with them the Some text. I dont want some text to be erased.
Please Help,
Thanks in advance,
Rabin
Rabin
Windows : Visual Basic 6 Enterprise / 3.0 (16-bit)
DOS : QBasic 4.5 , Visual Basic For DOS
Web : HTML , VBScript , PHP (Learning)
-
Apr 5th, 2001, 09:26 AM
#2
this is a guess
Code:
$open = fopen("file.html", "r");
$read = fread($open, 20000);
fclose($open);
$read = eregi_replace("<script>", "" , $read);
$read = eregi_replace("</script>", "" , $read);
-
Apr 5th, 2001, 09:28 AM
#3
never mind that wont work.
-
Apr 5th, 2001, 10:56 AM
#4
Thread Starter
Member
never mind that wont work.
Yeah, that'll just remove the <script> and </script> tags but the code will be displayed.
Rabin
Windows : Visual Basic 6 Enterprise / 3.0 (16-bit)
DOS : QBasic 4.5 , Visual Basic For DOS
Web : HTML , VBScript , PHP (Learning)
-
Apr 8th, 2001, 03:33 PM
#5
New Member
must use explode
Hi,
use explode() to chop up the string into an array, then loop through the array doing
$read[$i] = eregi_replace("<script>(.*)</script>", "" , $read[$i]);
on each element, then implode() all the parts back into a string
Hope that's not to confusing--i don't have enough time to provide sample code
Best Regards,
Bill Zeller
-
Apr 8th, 2001, 11:49 PM
#6
Thread Starter
Member
What should I use as a seperator for explode() ? </script> ?
Rabin
Windows : Visual Basic 6 Enterprise / 3.0 (16-bit)
DOS : QBasic 4.5 , Visual Basic For DOS
Web : HTML , VBScript , PHP (Learning)
-
Apr 9th, 2001, 06:25 PM
#7
New Member
yup, use </script>. Then do something like
eregi_replace("<script>(.*)", "", $var[$i])
If that doesn't clarify it I might just have to write up some working code
Best Regards,
Bill Zeller
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|