could someone tell me why this regex does not work in php, but the pattern works in c#?
I'm trying to replicate a working function that i have in c# and i tried to use the same regex pattern that i used there, it does not return any results, i checked google and understand that php regex uses a different set of delimiters but now i have no idea why it won't work.
php:
$results_q = "#(?m)/watch-.*?title=#";
preg_match($results_q, $html, $results, PREG_PATTERN_ORDER);
working in c#:
var results = Regex.Matches(test, "(?m)/watch-.*?title=");
how can i make it work in php? what are the differences in the pattern?
regex subject:
<a href="/watch-2742524-Thor-The-Dark-World" title="Watch Thor The Dark World (2013)">
output should be: /watch-2742524-Thor-The-Dark-World
This is my php function and it's currently working but only returning one result, i expect alot! as the page has several items on it matching my pattern.
function parseURL($url, $page, $featured = false) {
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n"
)
);
$context = stream_context_create($opts);
$html = file_get_contents($url, false, $context);
$results_q = "/(?m)watch-.*?title=/";
preg_match($results_q, $html, $results);
echo var_dump($results);
}