To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 4436
4435  |  4437
Subject: 
Re: Regular Expression help?
Newsgroups: 
lugnet.off-topic.geek
Date: 
Tue, 8 Jul 2003 15:53:37 GMT
Viewed: 
355 times
  
On Tue, Jul 08, 2003 at 03:39:54PM +0000, Andy Lynch wrote:
Hello Regular Expression Geeks.

I'm assuming you mean perl's regexps?

I need a hand... Could anyone help me to build a regular expression
for finding IMG tags in html files that do NOT have a "BORDER="
parameter?

I should note that you probably will have more reliable code if you
didn't use a regexp here, but instead parse the html with one of the
HTML::* modules...  but, regexp is more fun :)

for example:
<img src="foo.jpg">  matches
<img border="" src="foo.jpg">  no match
<img src="foo.jpg" border="0">  no match
<img src="foo.jpg" border="0" height="75">  no match
<img src="foo.jpg" width="50">  matches

I'm not sure if Regular Expressions can be used in this fashion, but
then I'm pretty new to them.

how about this:

print "$_ - no border" unless /<img[^>]+border="[0-9]*"/i;

Does that work for you?  Seems to pass your test cases.

Dan

--
Dan Boger
dan@peeron.com



Message has 1 Reply:
  Re: Regular Expression help?
 
(...) Hmmm, actually I am using an html editor that allows extended searches using regular expressions, so I am somewhat limited by what that allows. I should have been more specific. (...) That looks like it would work nicely, but as I said above, (...) (21 years ago, 8-Jul-03, to lugnet.off-topic.geek)

Message is in Reply To:
  Regular Expression help?
 
Hello Regular Expression Geeks. I need a hand... Could anyone help me to build a regular expression for finding IMG tags in html files that do NOT have a "BORDER=" parameter? for example: <img src="foo.jpg"> matches <img border="" src="foo.jpg"> no (...) (21 years ago, 8-Jul-03, to lugnet.off-topic.geek)

11 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR