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?
mmcwAsked:
Who is Participating?
 
andreifConnect With a Mentor Commented:
Please, let me know if this doesn't not work

$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
0
 
andreifCommented:
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gi;
0
 
andreifCommented:
sorry, this one:
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
mmcwAuthor Commented:
It will not work?
0
 
andreifCommented:
The second regext works perfectly

$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;

the difference is "s" modifier - it make . to match new line symbols.
0
 
andreifCommented:
Hi mmcw, does my example work? Have you any problem with this?
0
 
andreifCommented:
???
0
 
dimkCommented:
$list =~ s/<\!\-\- ads begin \-\->.*\<\!\-\- ads end \-\->//g;
0
 
ozoCommented:
Most of those \'s are unnecessary
0
 
mmcwAuthor Commented:
OZO: What would be your answer?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.