1

I have the following URL

https://website.com?id=XXXVVVCCCHHH

I only want XXXVVVCCCHHH, I've tried the following:

var phrase = 'https://website.com?id=XXXVVVCCCHHH'; 
var myRegexp = /id=(.*)/;
phrase = myRegexp.exec(phrase);

But this is returning: id=XXXVVVCCCHHH;

How can Ii edit this to only return XXXVVVCCCHHH?

Daft
  • 9,340
  • 14
  • 57
  • 96

1 Answers1

2

Just use split and take the second element:

var url = "https://website.com?id=XXXVVVCCCHHH";
var part = url.split('=')[1];
console.log(part);
Faly
  • 12,802
  • 1
  • 18
  • 35