JSFiddle - React, Tailwind, and code Playground

by jihyng_hd

JavaScript

txt = "喜愛烹飪, 透過鏡頭的方式同大家分享下廚的心得, 用\"一看你就明\"的簡單方法, 讓你都可以成為烹飪高手.\n\nFacebook : https://www.facebook.com/mic426\nInstangram : https://instagram.com/mic_michael\nYoutube : https://www.youtube.com/mic0426\n詳細食譜: http://micmiccooking.blogspot.hk\nE-mail : [email protected]";
//console.log(txt);
resultURL = txt.match(/https?:\/\/(\w\S+\.)+\w+\/?(\w|-|\/)*/g);
console.log(resultURL);
reusltEmail = txt.match(/\w\S+\@(\w\S+\.)+\w+/g);
console.log(reusltEmail);
var fb_account = [], yt_account = [], ig_account = [], tw_account = [], others = [];
$.each(resultURL, function(i,v) {
	if (v.search(/facebook/i) >0) {
  	fb_account.push(v.split("/")[3]);
  } else if (v.search(/youtube/i) >0) {
  	yt_account.push(v.split("/")[3]);
  } else if (v.search(/instagram/i) >0) {
  	ig_account.push(v.split("/")[3]);
  } else if (v.search(/twitter/i) >0) {
  	tw_account.push(v.split("/")[3]);
  } else {
  	others.push(v);
  }
})
console.log(fb_account);
console.log(yt_account);
console.log(ig_account);
console.log(tw_account);
console.log(others);