deleting HTML tag...but not everyone
From: Francesco Del Vecchio (f_delvecchio_at_yahoo.com)
Date: 07/29/04
- Next message: Jeff 'Japhy' Pinyan: "Re: sort files by extension"
- Previous message: Bob Showalter: "RE: Modifying @INC"
- Next in thread: Jenda Krynicky: "Re: deleting HTML tag...but not everyone"
- Reply: Jenda Krynicky: "Re: deleting HTML tag...but not everyone"
- Reply: James Edward Gray II: "Re: deleting HTML tag...but not everyone"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Jul 2004 05:52:48 -0700 (PDT) To: beginners@perl.org
Hi guys,
I have a problem with a Regular expression.
I have to delete from a text all HTML tags but not the DIV one (keeping all the parameters in the
tag).
I've done this:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#!/usr/bin/perl
use strict;
my $test=<<EOS;
<html><head><meta content="MSHTML 6.00.2800.1400" name="GENERATOR">
</head><body><font face="Courier New" size=2>
=========SUPER SAVING========= <br>
-product one <br>
-product two <br><D>
-product three <br><dIV section=true>
============================== <Br></DIV>
<br><br></font></body> </html>
EOS
$test=~s/<br>/\n/ig;
$test=~s/<^[DIV](.*?)>//ig;
print $test;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
with this I can hav ALMOST what I want.
I delete all HTML tags but <DIV> one but I also keep a <D> tag and I delete the </DIV> tag that I
would like to keep
The problem is in the ^[DIV] part of my regex....the "DIV" string is used as list of chars and not
as whole world. Is there a way to archieve my goal?
tnx in advance
Francesco
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail
- Next message: Jeff 'Japhy' Pinyan: "Re: sort files by extension"
- Previous message: Bob Showalter: "RE: Modifying @INC"
- Next in thread: Jenda Krynicky: "Re: deleting HTML tag...but not everyone"
- Reply: Jenda Krynicky: "Re: deleting HTML tag...but not everyone"
- Reply: James Edward Gray II: "Re: deleting HTML tag...but not everyone"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|