Answer the question
In order to leave comments, you need to log in
How to make preg_match for VK and Instagram?
Hello dear!
How to change the code:
// Convert user input social URLs to username values
$facebookUrl = $user->facebook;
preg_match("/https?:\/\/(www\.)?facebook\.com\/([^\/]*)/", $facebookUrl, $matches);
if ($matches){
$user->facebook = $matches[2];
}
$twitterUrl = $user->twitter;
preg_match("/https?:\/\/(www\.)?twitter\.com\/(#!\/)[email protected]?([^\/]*)/", $twitterUrl, $matches);
if ($matches){
$user->twitter = $matches[3];
}
$linkedinUrl = $user->linkedin;
preg_match("/https?:\/\/(www\.)?linkedin\.com\/in\/([^\/]*)/", $linkedinUrl, $matches);
if ($matches){
$user->linkedin = $matches[2];
}
$googleplusUrl = $user->googleplus;
preg_match("/https?:\/\/plus\.google\.com\/([^\/]*)/", $googleplusUrl, $matches);
if ($matches){
$user->googleplus = $matches[1];
}
$pinterestUrl = $user->pinterest;
preg_match("/https?:\/\/(www\.)?pinterest\.com\/([^\/]*)/", $pinterestUrl, $matches);
if ($matches){
$user->pinterest = $matches[2];
}
Answer the question
In order to leave comments, you need to log in
/https?:\/\/(www\.)?instagram\.com\/([^\/].+)/ # instagram username
/https?:\/\/(www\.)?vk\.com\/([^\/].+)/ # vk username
/https?:\/\/(www\.)?vk\.com\/id([^\/]\d+)/ # vk id123
You can still ask to finish it ... (nothing works for me)
https://plus.google.com/u/0/+Username + https://plus.google.com/u/2/Username/posts
https? :\/\/plus\.google\.com\/([^\/]*) #only
"u" is enough
https?:\/\/(www\.)?instagram\.com\/([^ \/].+)
#instagram cuts: "username/" - how to remove "/" at the end?
Nurlan Kasymov Stalker_RED
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question