Page 1 of 1
preg_match and regex - Help please!
Posted: Mon Sep 25, 2006 5:05 pm
by busin3ss
Hey! I have this issue... And it's driving me nuts! Everything I've tried doesn't work!
I want to preg_match from this line:
Code: Select all
<media:content url="http://static.flickr.com/87/252318706_4640fb66de_o.jpg" type="image/jpeg" height="520" width="426"/>
The url:
Code: Select all
http://static.flickr.com/87/252318706_4640fb66de_o.jpg
And I've tried
Code: Select all
preg_match("/src=\"http:\/\/static.flickr.com\/(.*).jpg\"/si",$rss,$r);
But It doesnt work...
Anyone could point me in the right direction?
Thanks in advanced!
Posted: Mon Sep 25, 2006 5:25 pm
by Benjamin
Code: Select all
<media:.*?url="(http://.*?\.jpg)".*?>
Will match
Code: Select all
<media:content url="http://static.flickr.com/87/252318706_4640fb66de_o.jpg" type="image/jpeg" height="520" width="426" / >
Posted: Mon Sep 25, 2006 5:39 pm
by busin3ss
Thanks! Just a quick question, and if I just want to match just the url, not the whole tag?
Thanks in advanced!
Posted: Mon Sep 25, 2006 5:39 pm
by patrikG
You're harvesting copyrighted flickr-photos?
Posted: Mon Sep 25, 2006 5:44 pm
by busin3ss
Ehmm... Nope... I just want to put in the sidebar of my blog my flickr images, but I'm trying to do it with my own code
Posted: Mon Sep 25, 2006 5:46 pm
by patrikG
Ah! Why not use their
API? Saves you the parsing, is more comfortable and probably faster.
Posted: Mon Sep 25, 2006 5:48 pm
by busin3ss
I already have a script that uses their API, and another one that uses MagPie RSS... But I want to do it with regex and preg_match this time, can you please put back the code that was already posted
Thanks in advanced!
Posted: Mon Sep 25, 2006 5:54 pm
by patrikG
it's back.
Posted: Thu Sep 28, 2006 1:38 am
by Benjamin
++example of overzelous moderator
Posted: Thu Sep 28, 2006 6:40 am
by Chris Corbyn
astions wrote:++example of overzelous moderator

There were reasons it was removed originally, and it was put back promptly. I don't think that statement was necessary.
Posted: Thu Sep 28, 2006 6:56 am
by Benjamin
d11wtq, I really respect your judgement and opinion, but I really feel that this is a good example of a moderator jumping the gun. Usually it's a different moderator, but never-the-less, for one to make an assumption that this was going to be used for illicit purposes is a bit out of line. But even if the user was planning on using it for illicit purposes, who are we to become the judge, jury and executioner?
He asked how to parse a string and he got an answer. The string he gave could have been a psuedo string. It could have said <media: microsoft blah>. I'm sorry, but I think devnet is starting to get a bit out of line. Would that other php forum site block stuff like that?
And then, add to that, this is a brand new forum member. What a warm welcome he received eh.
Posted: Thu Sep 28, 2006 7:05 am
by patrikG
Forum Rules wrote:9. Warez, copyright violation, or promotion of any other illegal activity may NOT be linked or expressed or posted in any form.
If anything, I was too lenient.
So as not to add more meta-discussion to this: if there is need for further discussion, I suggest to either (in this order) PM, post on the Forum Rules discussion thread or open a new thread in General Discussion.