...

View Full Version : I give up on preg match...



iceflyin
08-21-2007, 11:49 AM
For the life of me, I can't figure out how to parse a simple url out of this...



//$_POST[video]
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/nYH9b48msbs">
</param><param name="wmode" value="transparent"></param>
<embed src="http://www.youtube.com/v/nYH9b48msbs" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>




preg_match('/^(http:\/\/)?([^\/]+)/i', $_POST[video], $matchN);
$url = $matchN[1];
echo $url[0];
echo $url[1];
$url = $matchN[2];
echo $url[0];
echo $url[1];
$url = $matchN[0];
echo $url[0];
echo $url[1];
$url = $matchN[3];
echo $url[0];
echo $url[1];
$url = $matchN[4];
echo $url[0];
echo $url[1];

iceflyin
08-21-2007, 12:02 PM
Again... Not working..



"/(^http)([0-9a-zA-Z./])(\"$)/i"

iceflyin
08-21-2007, 12:31 PM
preg_match_all("'http(|[^>]*[^/])>(.*?)'si", $_POST[video], $items);
$array =$items[0];
echo ($array[0]). "-";
printf($array[1]). "-";
printf($array[2]). "-";
printf($array[3]). "-";

This gives me...

http://www.youtube.com/v/nYH9b48msbs\">-

Argh.... How can I make it end on the backslash?

iceflyin
08-21-2007, 12:45 PM
Somebody help... This is for a $2000 project I have to get done with in two days, and I can't figure out preg matches. The project is 90% completed.

I can't figure out how to make the preg match STOP at a certain character. None of the guides or tutorials help.

http://phpro.org/tutorials/Introduction-to-PHP-Regex.html

iceflyin
08-21-2007, 12:54 PM
Nm, got it... Finally, Orilley is the only person who knows wtf is going on!

"'(http)(.*?)(?=\\\\)'si"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum