There goes everything in a single REGEX, finished now:
//Retirar possíveis espaços na digitação
$odominioface = preg_replace('/([\s]+)/i', '', $_POST['link_do_facebook_profile']);
preg_match('/^(http(?:s)?[\:][\/][\/](?:www[\.])?facebook[\.]com[\/])(?:([a-z0-9\-\_]+)|(?:profile[\.]php[\?]id[\=]([0-9]{15})))$/i', $odominioface, $resultadodominioface);
if((isset($resultadodominioface[1]) == true) and ($resultadodominioface[1] != null)){
if((isset($resultadodominioface[2]) == true) and ($resultadodominioface[2] != null)){
echo "Puts grilla bicho eu achei o nome do perfil na URL! O nome é: ".$resultadodominioface[2]."<br />";
} elseif((isset($resultadodominioface[3]) == true) and ($resultadodominioface[3] != null)){
echo "Não encontrei o nome do perfil, mas pelo menos achei o id! O id é: ".$resultadodominioface[3]."<br />";
} else{
echo "Que mer* bicho! Não encontrei nada!<br />";
}
}
THE VARIABLES:
$resultadodominioface[1] ->
Returns the domain name, if not nouver this everything else is already disregarded in the script
$resultadodominioface[2] ->
The name of the guy in the URL is not required because the script doesn’t matter because it analyzes his existence or not.
$resultadodominioface[3] ->
The id of the guy
In this case I endorsed the variable ($resultadodominioface[1]), because if there is not a valid domain all the rest will be invalid, because everything depends on it. In this case the regular expression allows:
http://facebook.com/fulano
OR
https://facebook.com/fulano
http://facebook.com/profile.php?id=123789123456777
OR
https://facebook.com/profile.php?id=123789123456777
http://www.facebook.com/fulano OR https://www.facebook.com/fulano
http://www.facebook.com/profile.php?id=123789123456777
OR
https://www.facebook.com/profile.php?id=123789123456777
I did it now and I tried a lot! Thanks! I don’t need the script but if I need it, thanks to you, it’s ready! Thanks!
Remember that anything you can use
(?|)
to force a group to be able to get more than one :D result– Guilherme Lautert
@NGTHM4R3 now I think it looks pretty cool: http://ideone.com/8C6Fc3
– Bacco
Thank you, I’ll test.
– Thiago