Capture contents of a hrefs

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

Moderator: General Moderators

Post Reply
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Capture contents of a hrefs

Post by Roja »

I have a string that contains an entire webpage.

I need a regex that will return only items that start with: <a

and will end with: /a>

(it does need to include any title text, so the above requirements are literal)

Any help is deeply appreciated, as all my attempts have failed miserably.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Code: Select all

$pattern = "#(<a.*?/a>)#";
Post Reply