Regex...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thundza
Forum Newbie
Posts: 7
Joined: Fri Aug 06, 2004 9:44 pm

Regex...

Post by thundza »

Hey, I need to find a way to get the contents of a particular web page...

The contents i want to match are like this:
<b><font size=2>CONTENTS (some <BR> tags)</font></b>. I've tried lots of regex strings but none of them seem to work. I need to figure out what CONTENTS is.

preg_match('#<b><font size=2>(.*)</b>#', $html, $matches);
echo $matches[1];

and nothing seems to happen.
Any help is appreciated.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

seems like you should have a look at curl()

http://us2.php.net/manual/en/ref.curl.php
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: Regex...

Post by timvw »

thundza wrote:
The contents i want to match are like this:
<b><font size=2>CONTENTS (some <BR> tags)</font></b>. I've tried lots of regex strings but none of them seem to work. I need to figure out what CONTENTS is.

The easiest: use substr and strpos to grab it from $page

Use strpos to determine where <b><font size=2> is.
Then take substr to remove <b><font size=2> and everything before it.
Now use strpos where </font></b> is.
Then take substr and remove everything from </font></b>

done ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

curl? :roll:

Code: Select all

preg_match('#<b><font size=2>(.*?)</font></b>#i',$html,$match)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

Hey, I need to find a way to get the contents of a particular web page...
i should have read the thread more
Post Reply