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 / 4441
4440  |  4442
Subject: 
Re: Regular Expression help?
Newsgroups: 
lugnet.off-topic.geek
Date: 
Tue, 8 Jul 2003 18:44:29 GMT
Viewed: 
346 times
  
In lugnet.off-topic.geek, Andy Lynch wrote:
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 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 previously wrote the following to find IMG tags that had a border other than
"1":
<img[^>]*border="[02-9 ]?"[^>]*>

Which worked fine, accepting that parameters are all delimited by double quotes
in the files that I am working with.

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

Any assistance would be appreciated, thanks.
-Andy Lynch

For *BORDER* tags, you're in luck:

/<img(\s+[^bB]\w+=("[^"]"|\S*))*>/i

But that is on the (valid?) presumption that the ONLY attribute for an <img> tag
that starts with the letter "B" is "BORDER". I suppose I could be wrong what
with all the custom attributes that MSIE has, etc. But if there ARE other
attributes that start with B, then the above DOESN'T work, since it'll ignore
anything that's got an attribute that starts with B.

DaveE



Message has 1 Reply:
  Re: Regular Expression help?
 
(...) ^ missing "*" here --------/ (...) wouldn't this also break on this: <img src="1.jpg" alt="Some Text with Contrived B=something in it"> :) But other than that, good idea to look at what's valid :) (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