I want to get matches on a webpage based on following regular expression:
(.*)
I tested it on regexpal.com (an online regular expression test tool) and it works fine.
However, when I use it in php, I can’t find any matches. The statement I use in php is
preg_match_all("/<a href=\"\/title\/.*\/\">(.*)<\/a>/", $content, $matches);
I checked the $content, it’s correct. So is there anything wrong from my statement? Thanks!
Please, please… for the love of God, don’t wrap Regular Expressions that deal with URLs or HTML in /. You have to escape it all over the place. It’s terrible. Look here:
There’s more ways to improve this but this should do it.
Hope it helps.