I am trying to extract hash value from an magnet link but it returns undefined
var tesst = \"magnet:?xt=urn:btih:2B78EDFDDC87DC9605FB285997A80B787888C19
var test = tesst.match(/magnet:\?xt=urn:btih:([a-z\d]{40})\&/im);
You forgot the ( ) around the hash part.