generate functionTue, 13 Dec 2022

find youtube url int html string and replace it with embed iframe

function replaceUrlWithEmbed(html) { return html.replace(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g, '<iframe width="560" height="315" src="$&" frameborder="0" allowfullscreen></iframe>'); }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant