[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 145
  • Last Modified:

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?
0
mmcw
Asked:
mmcw
1 Solution
 
andreifCommented:
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gi;
0
 
andreifCommented:
sorry, this one:
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
0
 
mmcwAuthor Commented:
It will not work?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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:
Please, let me know if this doesn't not work

$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
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

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now