sharief has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks i need help with regular expression:
I want to change span tags only if it has font-weight: bold; as :
example:
Like this
<span style="font-weight: bold;color:#000000;"> <span style="font-family:Arial MT;font-size: 25px; font-weight: bold;" +> <span style="color:#000000;" xmlns="http://www.w3.org/1999/xhtml">
TO
I used expression:<span style="font-weight: bold;"> <span style="font-weight: bold;"> <span style="color:#000000;" xmlns="http://www.w3.org/1999/xhtml">
while($content =~ /<span style="(.*?)"/gi) { my $got=$1; if($got=~/font-weight: bold;/gi) { $content =~ s/<span style="(.*?)">/<span style="font-weight: bold;">/g +i; } }
There is no result for the above code
Any help for forming regular expression for this
Update: It seems the compiler goes to
Line 1:
<span style="font-weight: bold;color:#000000;">It extracts style content using
while($content =~ /<span style="(.*?)"/gi)Then i have assigned
$got=$1;So i will get $1 = font-weight: bold;color:#000000;
Then i check whether it has font-weight: bold; using if($got=~/font-weight: bold;/gi)
It has font-weight: bold; !!!
Now how will i move again to Line 1 to change it as
As per toolic $content =~ s/<span style="font.*/<span style="font-weight: bold;">/gi; this is not checking font-weight: bold;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expression
by toolic (Bishop) on Feb 02, 2012 at 14:32 UTC | |
|
Re: Regular expression
by roboticus (Chancellor) on Feb 02, 2012 at 14:12 UTC | |
|
Re: Regular expression
by JavaFan (Canon) on Feb 02, 2012 at 14:42 UTC |