I'm trying to match a URL in a string of text and I'm using this regex to search for a URL :
/\b(https?:\/\/.*?\.[a-z]{2,4}\b)/g
The problem is, it only ever matches the protocol and domain, and nothing else that follows.
Example :
let regEx = /\b(https?:\/\/.*?\.[a-z]{2,4}\b)/g;
let str = 'some text https://website.com/sH6Sd2x some more text';
console.log(str.match(regEx));
Returns :
https://website.com
How would I alter the regex so it will return the full URL?
https://website.com/sH6Sd2x
Working Demo :
let regEx = /\b(https?:\/\/.*?\.[a-z]{2,4}\b)/g;
let str = 'some text https://website.com/sH6Sd2x some more text';
console.log(str.match(regEx));