-2

I have this simple code:

<a href="subsc.php?English" class="price_button pb_red">Subscribe today</a>

when the user press on the a tag it takes him to the page subsc.php?English.
My question is how can i get the information after the ? (which is "English" in this example)?

Alessio Cantarella
  • 5,077
  • 3
  • 27
  • 34
Ys3
  • 79
  • 1
  • 2
  • 7
  • 1
    `window.location.search` – Gabriele Petrioli Jan 20 '20 at 11:12
  • Prefixing your question title with “javascript” and typing it into Google, would have lead you there straight away. Please make an actual research effort, before you ask about stuff like this. – 04FS Jan 20 '20 at 11:12

1 Answers1

0

You can try with Regex Positive Lookbehind /(?<=\?).$*/.

var url = '/subsc.php?English';
var r = url.match(/(?<=\?).*$/)[0];
console.log(r);
Mamun
  • 66,969
  • 9
  • 47
  • 59