Regular Expressions
From: Andrew Bullock (trullock_at_yahoo.com)
Date: 03/10/04
- Next message: Good Man: "Re: PHP Script Can't Connect To MySQL Server..."
- Previous message: Good Man: "Re: PHP Script Can't Connect To MySQL Server..."
- Next in thread: Tim Van Wassenhove: "Re: Regular Expressions"
- Reply: Tim Van Wassenhove: "Re: Regular Expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Mar 2004 14:32:01 -0000
Hi
Im REALLY stuck with regular expressions!
Can someone please give me a pointer with this...
Im trying to extract a load of images from a site, which are in hrefs.
ie. i want to extract the url and image path
typical hrefs would be:
<a href="test.html"><img src="clickme.jpg"></a>
<a target=_top href="test.html"><img border=0 src="clickme.jpg"></a>
<a href='test.html'> <img src=clickme.jpg></a>
as you can see, there may me double quotes, single quotes or no quotes
surrounding the image and url path, so i need to be able to account for
this.
Also i only want to return info, where there is a jpeg as an image to click,
and the url is a html.
Does that make sense?
$matchstr =
'/<a\s+.*?href=[\"\'s]?(.*?)\"?+src=[\"\'s]?(.*?)\"(.*?)\>\<\/a\>/i';
That almost works, but it returns this :
test.html"><img
thumbs/16.jpg>
how can i fix this?
Many thanks in advance
Andrew
- Next message: Good Man: "Re: PHP Script Can't Connect To MySQL Server..."
- Previous message: Good Man: "Re: PHP Script Can't Connect To MySQL Server..."
- Next in thread: Tim Van Wassenhove: "Re: Regular Expressions"
- Reply: Tim Van Wassenhove: "Re: Regular Expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|