2012-09-07, 09:55 AM
I'm having trouble getting my regex pattern to work. I've never been very good at it, and don't really know how it works in PHP.
From my understanding, I have to use preg_match_all to get all occurrences of a particular pattern correct?
This is what I want:
I have pages on my site like:
<a href="http://tomkent.me/user-12345.html">User1</a>
I want to get the User1 bit of the html, from a page containing about 50 of these URLs
I tried:
as well as (escaping some things):
But neither work when I try to output:
Any help would be appreciated
From my understanding, I have to use preg_match_all to get all occurrences of a particular pattern correct?
This is what I want:
I have pages on my site like:
<a href="http://tomkent.me/user-12345.html">User1</a>
I want to get the User1 bit of the html, from a page containing about 50 of these URLs
I tried:
preg_match_all('<a href="http://tomkent.me/user-(.*).html">(.*?)</a>',$html,$matches);
as well as (escaping some things):
preg_match_all('<a href\=\"http\:\/\/tomkent\.me\/user\-(.*)\.html\">(.*?)<\/a>',$html,$matches);
But neither work when I try to output:
print_r($matches);
Any help would be appreciated