JSFiddle - React, Tailwind, and code Playground
by a13xs
JavaScript
function validatePage(page) {
var re = /(?:(?:http|https):\/\/)?(?:www.)?facebook\.com\/[\w*\d\.*]+/gm;
var url = page.match(re);
if (url === null || url[0] === undefined) {
return '';
}
return url[0];
}
function validatePost(post) {
const re = /posts\/\d+/gm;
const postId = post.match(re);
if (postId == null || postId[0] === undefined) {
return '';
}
const id = postId[0].replace('posts/', '');
if (id == null) {
return '';
}
return id;
}
//console.log(validatePage('https://www.facebook.com/worldopo/settings/?tab=people_and_other_pages'));
console.log(validatePost('https://www.facebook.com/BugginhoDeveloper/posts/575327262637013'));