[Tutor] Finding text in a long string

David Broadwell dbroadwell@mindspring.com
Mon Jun 16 23:36:01 2003


<snippy-snip>
> http://domain.com/image1.gif or it might be ../images/image1.gif or
> I get the same error.  I've tried.  Because the location of 
> "image1.gif" can change and it could be either a relative location
> or an absolute location, the following doesn't work either:
I see you are trying to match against a 'image1.gif' as a whole string
entire. Based on what you wrote, it doesn't seem to exist that way.

> I feel like a regular expression would help here, but I'm not sure how I
> would do this.  Any suggestions?
Seeing as I don't know regular expressions, can't help with that.

Try matching against the entire tag that you want to match instead of
just that one part, and perhaps searching once and if not found search
again for the other possibility.

Or continuing with your method, you might need to take one of the lines
from the file into the interpreter and see exactly what splits will
render it down to the data you are looking for. Step through it in the
interpreter with the debugger. Or some well placed print statements.

The method looks to be workable.

Python is good, it's not omniscient. Were that and programming language
was, we might not need programmers.

(I don't see that happening anytime soon.)

--

David Broadwell