CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
exclude a string in pattern

 



amoskoh
New User

Apr 12, 2005, 10:42 AM

Post #1 of 2 (4278 views)
exclude a string in pattern Can't Post

OK. here it goes

I havea String with HTML-like tags
ie,
<TIME> 11.00pm </TIME><ENAMEX> test </ENAMEX>

I want to clean that string by removing all things that come in between the < >
EXCEPT
<ENAMEX>
<ENAMEX etc etc... may be anything>
</ENAMEX>

And running that on the example string should produce something like
11.00pm <ENAMEX> test </ENAMEX>

Hence removing only the tags not the stuff in between and the ENAMEX tags



Im having trouble to come up with a regular expression that matches the tags (stuff in between < >) but doesnt match those ENAMEX tags.


kencl
User

Apr 13, 2005, 8:06 PM

Post #2 of 2 (4266 views)
Re: [amoskoh] exclude a string in pattern [In reply to] Can't Post

This seems to work:

Code
$string =~ s{(<.*?>)}{ $tag = $1; $tag =~ /^<\/?ENAMEX/ ? $tag : ''}ge;


>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives