mmcw
asked on
How to remove a part of a text.
How to remove a part of a text.
I have the folling text:
-------------------------- ---------
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN="3">
<br><br>
<!-- ads begin -->
<center>
bla bla bla bla
<!-- ads end -->
</td>
</tr>
</table>
</body>
</html>
-------------------------- ---------- --
This is stored in $list.
I want to remove to text from <!-- ads begin -->
till <!-- ads end -->
Incl. <!-- ads begin --> and <!-- ads end -->.
How do do that?
I have the folling text:
--------------------------
</TR>
<TR>
<TD ALIGN="CENTER" COLSPAN="3">
<br><br>
<!-- ads begin -->
<center>
bla bla bla bla
<!-- ads end -->
</td>
</tr>
</table>
</body>
</html>
--------------------------
This is stored in $list.
I want to remove to text from <!-- ads begin -->
till <!-- ads end -->
Incl. <!-- ads begin --> and <!-- ads end -->.
How do do that?
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gi;
sorry, this one:
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
ASKER
It will not work?
The second regext works perfectly
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
the difference is "s" modifier - it make . to match new line symbols.
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
the difference is "s" modifier - it make . to match new line symbols.
Hi mmcw, does my example work? Have you any problem with this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
???
$list =~ s/<\!\-\- ads begin \-\->.*\<\!\-\- ads end \-\->//g;
Most of those \'s are unnecessary
ASKER
OZO: What would be your answer?