I am trying to match this url:
https://play.spotify.com/user/randomuser/playlist/71ljVu3Ejccu2PzW6iXv0G
where random user and the ending id are changing.
I want to verify that the url is indeed a play.spotify.com link and matches that format.
I have this javascript function:
var verify = function(url){
var re = new RegExp("(https:\/\/play.spotify.com\/user\/\w+?\/playlist\/\w+)", "g");
var result = re.exec(url);
console.log(result);
}
verify("https://play.spotify.com/user/useruser/playlist/71ljVu3Ejccu2PzW6iXv0G");
When I tested it out using a regex tester, it seems to work correctly:

The output of the console.log, however, is just null.
What am I doing wrong in the javascript? Why isn't the url properly matching?
RegExpconstructor, use a regex literal..s into\.s.