The Regex:
https?://([a-zA-Z0-9-_]{1,50}[.])*[a-zA-z0-9-_]{1,50}[.]([(org)(gov)(com)]{3}|[(us)(fi)]{2})
The Tester:
http://regex.powertoy.org/
The Code:
if(preg_match_all('|https?://([a-zA-Z0-9-_]{1,50}[.])*[a-zA-z0-9-_]{1,50}[.]([(org)(gov)(com)]{3}|[(us)(fi)]{2})|',$row['text'],$links))
{
print_r($links[0]);
/*for($x=0;$x<count(links[0]);$x++)
{
$row['text'] = str_replace($links[0][$x], 'link' . $link[0][$x] . 'link', $row['text'];
}*/
}else{
echo 'Failure!';
}
The regex matches URLs in the tester fine, but not at all in an HTML/PHP front end. I'm not sure what the problem is. The point of the regex/code is basically to match URLs regardless of the number of subdomains.