Regex help

I’m stuck at regex again, basically, I need to get the following from this page using PHP:

In the source of

If you decode this, and split them up, the output is:,5,gibbs,rap,hip,hop,gary,indiana,g.i.,midwest,big,bizness&cr=AU&rv.1.url=,5/0/7/0/0&,rv:vXCkaDciWHw&rv.5.url= Gibbs - Im A Hustla&sourceid=yw&timestamp=1270170515&,5/0/7/0/0&hl=en_US&rv.0.thumbnailUrl= Eazy-E feat. Bone Thugs - This Ain't A Game& Gibbs - Stay High remix&rv.4.length_seconds=73&rv.1.thumbnailUrl=,5

All I want from this is:,5,5

My script is currently working for some things, but not for others.

Can you help me get those 3 things in the above code from the source?


I’m not sure why you need the same thing 3 times?

Some pages have 2 or 3 different links, hence me getting 3 results to parse a different one randomly.

If you can get me 1 result successfully it’ll be fine.

Here’s how I recreated the first one.
If $text = the first string you gave, then…

$data = explode('%7C',$text);
$search = array('%3A','%2F','%3F','%3D','%26','%25');
$replace = array(':','/','?','=','&','%');
$string = str_replace($search,$replace,$data[1]);
$string = explode('=',$string);
$string[(count($string)-1)] = str_replace('%2C',",",$string[(count($string)-1)]);
$string = implode('=',$string);

$string is now set to the first line you gave as your result.

I can get that with split and urldecode… I want to get the code from YouTubes source ready to parse, thats all I need help with.

I’m not sure what you’re asking for. Your original post asks for a way to go from A to B… now it sounds like you’re asking how to get A out of the HTML source?

If so, it depends on what setup your server is using… cURL can get the data… fopen/fread…file_get_contents… and then you just manipulate it as you would a string. (or throw it through a parser and handle it that way).

I said I need to get the following from the page, meaning I need to get the first quote out of the YouTube source.

Any further help is appreciated.