detect youtube link in text and convert it to embed
function getYoutubeEmbedLink(text) { var regExp = /^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; var match = text.match(regExp); if (match && match[2].length == 11) { return 'https://www.youtube.com/embed/' + match[2]; } else { return false; } }