Extracting html information

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

Moderator: General Moderators

Locked
simonk
Forum Newbie
Posts: 3
Joined: Mon Apr 03, 2006 11:58 am

Extracting html information

Post by simonk »

I have the following code stroed in a html file:

<div class="class1">
<a href="http://www.yahoo.com">Yahoo</a>
A search engine
<div class="category">search</div>
</div>

How can I use regular expression to extract the link 'www.yahoo.com', the name 'Yahoo' and the description and the category 'Search' into one array?

I know I should use the preg_match and {} but I just cant get this work..

Please help,
Many many thanks.

CF K
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Have you looked in the The Useful posts thread?


feyd | locked, cross posting.
Locked