I have made a Regular expression that captures the Short URL of a link. For example:
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=picture%20of%20a%20potato
My regular expression would be:
/(https:\/\/.+?)\/.+/
Now this would only capture:
https://www.google.com
What I want to do now is store the captured RegEx into a variable. Any help or suggestions are greatly appreciated.
.match()
it returns an array containing the match and all the capture groups. BTW, there's no point in putting a capture group around the entire regexp./(https?:.*?\.{1,3})/gi
won't capturehttps://www.google.com