I'll apologize in advance for being a newb, I'm pretty new to the world of programming so show some mercy XD
I'm trying to make a script that will copy only the account name from the top browser URL but I've hit a brick wall on this part.
const regex = /account\/(.*)\/#photos/gm;
const str = `https://internal.DUMMYSITE.com/compliance/account/ACCOUNTNAME/#photos`;
let m = regex.exec(str);
var dummy = document.createElement(m),
text = window.location.href;
document.body.appendChild(dummy);
dummy.value = text;
dummy.select();
document.execCommand('copy');
document.body.removeChild(dummy);
So it works fine for the most part, in my actual code I've used a random URL that follows the format and the "ACCOUNTNAME" part is actually a real account name. Every time I run the code it copies the text that I've added on the account name.
What am I doing wrong?
I'll thank everyone in advance, cheers!