Matching certain links

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
socket1
Forum Commoner
Posts: 82
Joined: Mon Dec 08, 2008 7:40 pm
Location: Shokan, New York

Matching certain links

Post by socket1 »

I have a page with many links that look like <a href="linked_page-number.html">Reply</a>
I'm trying to use preg_match_all to match all the occurrences of that link regardless of the page name so I can extract the page name and have all of the page names in an array.

I've tried some expressions but they all seem to fail.

This is the closest thing that I've gotten that doesn't return an error:
/<a href="(\d*)">Reply<\/a>/


EDIT: I found/made one that works
/<a href="[^"]+">Reply<\/a>/
Now I just have to take the array and extract the page names.
Post Reply