Help for this page

Select Code to Download


  1. or download this
    $x = "<tr><td>1</td><td>2</td><td><font>3</font></td><td>4</td><tr>";
    
    $x =~ s{<td>(?!<td>)3(?!</td>)</td>}{<td>($1)a($2)</td>}; 
    print $x;
    #output must be: <tr><td>1</td><td>2</td><td><font>a</font></td><td>4<
    +/td><tr>
    
  2. or download this
    $text =~ s/(<td>)((?:(?!<td>).)*)3((?:(?!<\/td>).)*)/<td>$1$2a$3/;
    OR
    $text =~ s{(?<=<td>)((?:(?!<td>).)*)3((?:(?!</td>).)*)(?=</td>)}{$1a$2
    +};