xxxxxxxxxx
var torrent = "magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C";
if (torrent.match(/magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32}/i) !== null)
{
console.log("It's valid, bloody fantastic!");
}
xxxxxxxxxx
var magnet_link = document.getElementById('link').innerHTML;
if (magnet_link.match(/magnet:\?xt=urn:[a-z0-9]{20,50}/i) != null) {
alert('Link is valid');
}