-1

I have a javascript string that looks like this:

Thanks for choosing our services (https://servicesnow.com)!! Download receipt <https://support.com/site/voucher?email=vrome@OkopRI.SG&hash=2f95f5d774e44f6543c74fcc4e235f8b8eb9cf>

I would like to find a regex that extracts the receipt link:

https://support.com/site/voucher?email=vrome@OkopRI.SG&hash=2f95f5d774e44f6543c74fcc4e235f8b8eb9cf

What I tried so far is this: .match(/\b(https?://.*?.[a-z]{2,4}\b)/g);

but unfortunately it matches the first http. How can I do that? thanks

toumperlekis
  • 39
  • 1
  • 9

1 Answers1

3

It's as simple as this:

var string = "Thanks for choosing our services (https://servicesnow.com)!! Download receipt <https://support.com/site/voucher?email=vrome@OkopRI.SG&hash=2f95f5d774e44f6543c74fcc4e235f8b8eb9cf>";
var url = string.match(/\<(.*)\>/).pop();
console.log(url);

You can use the < and > chars as a delimiter.

obscure
  • 11,916
  • 2
  • 17
  • 36