Subject:
|
Regular Expression help?
|
Newsgroups:
|
lugnet.off-topic.geek
|
Date:
|
Tue, 8 Jul 2003 15:39:54 GMT
|
Viewed:
|
361 times
|
| |
| |
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
|
|
Message has 2 Replies: | | Re: Regular Expression help?
|
| (...) I'm assuming you mean perl's regexps? (...) 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 :) (...) how about (...) (21 years ago, 8-Jul-03, to lugnet.off-topic.geek)
| | | Re: Regular Expression help?
|
| (...) 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 (...) (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
|
|
|
|