I would like to get the urls from a webpage that starts with "../category/" from these tags below:
<a href="../category/product/pc.html" target="_blank">PC</a><br>
<a href="../category/product/carpet.html" target="_blank">Carpet</a><br>
Any suggestion would be very much appreciated.
Thanks!
No regular expressions is required. A simple XPath query with DOM will suffice:
Will print:
This regex searches for your
../category/
string:All text literals are used for matching. You can replace the ..... to make it more specific. Only the
\.
need escaping. The.*?
looks for a variable length string. And()
captures the matched path name, so it appears in $matches. The manual explains the rest of the syntax. http://www.php.net/manual/en/book.pcre.php