Re: "negative" regexp
- From: "Petr Vileta" <stoupa@xxxxxxxxxxxxx>
- Date: Wed, 30 Jan 2008 16:10:15 +0100
Abigail wrote:
_Thanks, this work OK.
Petr Vileta (stoupa@xxxxxxxxxxxxx) wrote on VCCLXV September MCMXCIII
in <URL:news:fnoj8a$1hin$1@xxxxxxxxxxxxxxx>:
;; I have problem to construct regexp, this is out of my brain ;-)
please help. ;;
;; I have string
;;
;; $string="<a href='big.gif'><img src='small.gif'></a><br><a
;; href='abc.htm'><b>click</b></a>";
;;
;; and I need to remove all html tags except <img ...>. The result
should be ;;
;; $string="<img src='small.gif'>click";
;;
Well, for your example,
s/<(?!img)[^>]*>//g
I'm tending to not use HTMP parsers because these construct a huge hashes and this is usually not needed for my purposes.
The "right" way to do it is to use a proper HTML parser.
Get one from your nearest CPAN.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
.
- References:
- "negative" regexp
- From: Petr Vileta
- Re: "negative" regexp
- From: Abigail
- "negative" regexp
- Prev by Date: Re: List of directories within a directory
- Next by Date: Re: Get an arbitrary hash key, quickly.
- Previous by thread: Re: "negative" regexp
- Next by thread: Re: "negative" regexp
- Index(es):
Relevant Pages
|