"negative" regexp
- From: "Petr Vileta" <stoupa@xxxxxxxxxxxxx>
- Date: Wed, 30 Jan 2008 02:10:04 +0100
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";
Now I do it this way
# replace < with Ctrl-B and > with Ctrl-E for all <img> tags
$string=~s/<img\s+(.+?)>/\cb$1\ce/g;
# remove all html tags
$string=~s/<.+?>//g;
# replace back all Ctrl-B with <
$string=~s/\cb/</g;
# replace back all Ctrl-E with >
$string=~s/\ce/>/g;
but maybe exist another way.
--
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>
.
- Follow-Ups:
- Re: "negative" regexp
- From: Abigail
- Re: "negative" regexp
- Prev by Date: Re: uniq without sort <-------------- GURU NEEDED
- Next by Date: ssh into remote nodes, do mulitple commands
- Previous by thread: domains, top level, collecting a list of
- Next by thread: Re: "negative" regexp
- Index(es):
Relevant Pages
|