0

My subject is

some html codes<h3 class="r"><a href="/url?q=http://www.somedomain.com/args/">Some Title</a></h3>some html codes

My current pattern is:

"/<h3 class="r"><a href="\/url?\?q\=http(...)/"

The result is:

<h3 class="r"><a href="/url?q=http://

I wanted to get the exact url, http://www.somedomain.com/args/ or just <h3 class="r"><a href="/url?q=http://www.somedomain.com/args/">Some Title</a></h3> so i can parse it to return the url.

but i could not make it.

Any help would be appreciated. Thank you!

user1732887
  • 288
  • 1
  • 2
  • 9
  • possible duplicate of [How do you parse and process HTML/XML in PHP?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – Sverri M. Olsen Apr 14 '14 at 01:52
  • Try this regex with `preg_match_all()`: `\b(https?://[^\s()<>]+\.[^\s()<>]+)\b`. [See **demo**](https://eval.in/136152) – Amal Murali Apr 14 '14 at 03:58

2 Answers2

0

LIVE DEMO

Try this:

'/<h3 class="r"><a href="\/url?\?q\=(http.*)\/"/'
CMPS
  • 7,733
  • 4
  • 28
  • 53
0
$string = 'some html codes<h3 class="r"><a href="/url?q=http://www.somedomain.com/args/">Some Title</a></h3>some html codes'
preg_match_all('!http://(.*)"!', $string, $result_array);
print_r($result_array);

Try it.