Link to home
Start Free TrialLog in
Avatar of mmcw
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?
Avatar of andreif
andreif
Flag of Canada image

$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gi;
sorry, this one:
$list =~ s/<\!\-\- ads begin \-\->.*?<\!\-\- ads end \-\->//gis;
Avatar of mmcw
mmcw

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.
Hi mmcw, does my example work? Have you any problem with this?
ASKER CERTIFIED SOLUTION
Avatar of andreif
andreif
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
???
$list =~ s/<\!\-\- ads begin \-\->.*\<\!\-\- ads end \-\->//g;
Avatar of ozo
Most of those \'s are unnecessary
Avatar of mmcw

ASKER

OZO: What would be your answer?