Jump to content

preg_match_all


phorcon3

Recommended Posts

here's the string

 

<a href="/online/frame.htm?si=2m70n.1jpqGQ.1rgs6v.C**&v=1">

 

and i have to find

 

/online/frame.htm?si=2m70n.1jpqGQ.1rgs6v.C**&v=1

 

and i tried using:

 

<?php

$html = '<a href="/online/frame.htm?si=2m70n.1jpqGQ.1rgs6v.C**&v=1">';

preg_match_all('/href="/online/frame.htm?si=(.*?)&v=1"/', $html, $match);

$find = $match[1][0];

echo $find;

?>

 

but it just wouldn't output anything. any ideas to why that is?

 

<?php

preg_match_all('/frame.htm?si=(.*?)&v=1/', $result, $matches);

?>

 

doesn't work either.

Link to comment
https://forums.phpfreaks.com/topic/90993-preg_match_all/
Share on other sites

that's cuz ya using the delimeters within the patters

 

/ # set start/end delimeter

href="/online/frame.htm?si=(.*?)&v=1" # our search pattern

/ # end delimeter

 

so it will just look for href="

and think everything beyond that is a optional preg parameter (not a pattern)

 

easiest way change the delimeter

@href="/online/frame.htm?si=(.*?)&v=1"@

 

 

Link to comment
https://forums.phpfreaks.com/topic/90993-preg_match_all/#findComment-466360
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.