generate functionThu, 08 Dec 2022

detect youtube link in text and replace it with embed

function youtube_parser(url){ var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; var match = url.match(regExp); return (match&&match[7].length==11)? match[7] : false; }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant