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 / 4437
4436  |  4438
Subject: 
Re: Regular Expression help?
Newsgroups: 
lugnet.off-topic.geek
Date: 
Tue, 8 Jul 2003 17:05:17 GMT
Viewed: 
356 times
  
Dan Boger wrote:
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?

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.


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?

how about this:

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

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

Dan

That looks like it would work nicely, but as I said above, I am using this
in the context of an html editor, and so I don't have access to perl from
the application's extended search box.  One of my co-workers would like to
clean up the code in several hundred html files and borders would only be
the first parameter to be checked, later would be height, width, etc.  The
content that we are working with has been purchased by our organization and
we will be hosting on our own site, but it is not really up to our coding
standards.

My examples above were actually intended to be snippets from inside complete
html files, not just a list of img tags.  I'm not sure if that was clear.

Thanks for the suggestion though, Dan. :-)

-Andy Lynch



Message has 1 Reply:
  Re: Regular Expression help?
 
(...) oh! well, seems that it has a similar syntax :) Anyway, the actual regexp here is: <img[^>]+border="[0-9]*" Hope that will help. By the way, if you need to edit hundreds of lines, using an automated process might save you hours and hours of (...) (21 years ago, 8-Jul-03, to lugnet.off-topic.geek)

Message is in Reply To:
  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)

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