2

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
  • 10,277
  • 15
  • 63
  • 105

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
  • 13,291
  • 2
  • 19
  • 37