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;
In reply to Regular expression by sharief
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |