$string = 'this is my text string <script type="text/javascript">char(13) + char(10)function popup(theURL) { char(13) + char(10) popup_large(theURL); char(13) + char(10)char(13) + char(10)}char(13) + char(10)function popup_large(theURL) { char(13) + char(10) if (theURL != "")char(13) + char(10) {char(13) + char(10) var win = window.open(theURL, "PopupLarge",char(13) + char(10) "scrollbars=yes,width=820,height=530,resizable=yes");char(13) + char(10) win.focus();char(13) + char(10) }char(13) + char(10)}char(13) + char(10)</script> blah blah ';

$string =~ s/(<script.*?>.*<\/script>)//;

print "$string\n";

Bobby wrote:
I need a better solution. Here's the whole block of text that i have to remove from my text file. Thanks for any suggestions.
"<script type="text/javascript">char(13) + char(10)function popup(theURL) { char(13) + char(10)    popup_large(theURL); 
char(13) + char(10)char(13) + char(10)}char(13) + char(10)function popup_large(theURL) { char(13) + char(10)    if (theURL != 
"")char(13) + char(10)    {char(13) + char(10)        var win =  window.open(theURL, "PopupLarge",char(13) + char(10)     
                  "scrollbars=yes,width=820,height=530,resizable=yes");char(13) + char(10)        win.focus();char(13) + char(10)   
 }char(13) + char(10)}char(13) + char(10)</script>"

--- On Mon, 1/19/09, Bobby <cybercruis...@yahoo.com> wrote:

From: Bobby <cybercruis...@yahoo.com>
Subject: Re: Removing block of text in string
To: beginners@perl.org
Date: Monday, January 19, 2009, 1:30 PM
I'm using search and replace to solve this issue unless
someone else have a better idea. Thanks.
my $removeText="<script>
type="text/javascript">function....</script>";
$string = ~s/$removeText//gi;


--- On Mon, 1/19/09, Bobby <cybercruis...@yahoo.com>
wrote:

From: Bobby <cybercruis...@yahoo.com>
Subject: Removing block of text in string
To: beginners@perl.org
Date: Monday, January 19, 2009, 12:00 PM
Hi,

I have a javascript function in my long text string
that i
want to remove, how do i remove a text string from
starting
point to an ending point so that the javascript block
<script> to </script> is remove from my
text
string? Thanks.
Current:
string = "this is my text string <script

type="text/javascript">function....</script>
blah blah..."

Desired Result:
string = "this is my text string blah
blah..."


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
beginners-h...@perl.org
http://learn.perl.org/
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to