0

I am trying to get website adresses from a webpage. The pattern is always:

    <br />i <a href="http://www.website.com"

The part I need is www.website.com. After reading a lot I made this;

    "preg_match('@^(?:<br />i <a href="http://)?([^/]+)@i' , $html, $matches);"

but I think I made a mistake... Someone who can help me ?

I've put my "solution" between brackets because stackoverflow makes a mess of it...

Dimitri Visser
  • 155
  • 2
  • 12
  • The `^` anchor means start of subject. * See also [Open source RegexBuddy alternatives](http://stackoverflow.com/questions/89718/is-there) and [Online regex testing](http://stackoverflow.com/questions/32282/regex-testing) for some helpful tools, or [RegExp.info](http://regular-expressions.info/) for a nicer tutorial. – mario Feb 03 '13 at 01:24
  • Thank you, but I found this solution after reading these manuals for several hours...And it still doesn't work.. – Dimitri Visser Feb 03 '13 at 01:25
  • i'm not skilled with regex, to do something like this I'd try with a html parser – lelloman Feb 03 '13 at 01:25

1 Answers1

0

Try this:

preg_match( '/<br \/>i <a href="http:\/\/([^"]+)"/', $html, $matches );
Andreas Hagen
  • 2,335
  • 2
  • 19
  • 34