On Thursday, Mar 20, 2003, at 06:00 US/Pacific, Kipp, James wrote:
I'm making something, and need to block out BGCOLOR attribute. The problem is, the BGCOLOR could be with or without quotation marks. This is the code I used:
$article =~ s/ bgcolor=("?)(.*?)("?)//gi
so you are saying it could be bgcolor or "bgcolor" ? how about something simple like: $article =~ s/bgcolor|\"bgcolor\"//gi;
no, the problem is on the other side of the "=" token
eg: <body bgcolor="#999999"> or <body bgcolor=red> or <body bgcolor="red">
and he would like to make that
<body>
I would of course go with say:
#------------------------ # sub un_colour { my ($line) = @_; $line =~ s/\s*bgcolor=("?)([^">\s]+)("?)//gi ;
$line; } # end of un_colour
since the middle element needs to guard against
a. " b. > c. white space
ciao drieux
---
my $l1 = '<body bgcolor="#999999" other="fred"> stuff here <table bgcolor=blue> '; my $l2 = '<body bgcolor=red other="fred">'; my $l3 = '<body bgcolor="red" other="fred">'; foreach my $tag ( $l1 , $l2 , $l3 ) { my $answer = un_colour($tag); print "#-----------\n$answer\nfor $tag \n"; } #------------------------ # sub un_colour { my ($line) = @_; $line =~ s/\s*bgcolor=("?)([^">\s]+)("?)//gi ; $line; } # end of un_colour
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]