Hi,
I'm attempting to get ereg() to extract URLs, and I don't see why this code won't do it. Any help would be appreciated.
<?php
$testvar="aaaahttp://www.test.combbbb";
ereg("(.)(([url]http://[/url]){1}(.)(/.)?(.)(/.com|/.net|/.org){1})+(.)$", $testvar, $matches);
print $matches[2]."\n";
?>
Here's what I was thinking on the expression:
(.) // the string can start with any/no character
(([url]http://[/url]){1} // look for instances where [url]http://[/url] is shown once
(.) // allows for www or any other subdomain.
(/.) // look for the . once or zero times, depending on the url
(.)// the domain name
(/.com|/.net|/.org){1})+ //locate the ending com,net, or org once. also, there must be atleast one url.
(.)$ // allow for any other characters, then end the string.