Page 1 of 1

Regex...

Posted: Sun Aug 29, 2004 6:26 pm
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.

Posted: Sun Aug 29, 2004 6:42 pm
by tim
seems like you should have a look at curl()

http://us2.php.net/manual/en/ref.curl.php

Re: Regex...

Posted: Sun Aug 29, 2004 7:00 pm
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 ;)

Posted: Sun Aug 29, 2004 7:15 pm
by feyd
curl? :roll:

Code: Select all

preg_match('#<b><font size=2>(.*?)</font></b>#i',$html,$match)

Posted: Sun Aug 29, 2004 7:47 pm
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