I want to extract the first valid URL in a string, which can be anywhere between characters and whitespace
I have tried with the following
...
urlRegex: /^http[s]?:\/\/.*?\/([a-zA-Z-_]+).*$/,
...
var input = event.target.value // <--- some string;
var url = input.match(this.urlRegex)[0];
Problem is url returns the whole string when it finds a url, instead of returning just the part of the string matching the regex
How can this be achieved?
Aucun commentaire:
Enregistrer un commentaire