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

<span style="font-weight: bold;"> <span style="font-weight: bold;"> <span style="color:#000000;" xmlns="http://www.w3.org/1999/xhtml">
I used expression:
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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.