title: Extracting for URL from string using regex
body: <p>I want to extract the first valid URL in a string, which can be anywhere between characters and whitespace</p>
  
  <p>I have tried with the following</p>
  
  <pre><code>...
  urlRegex: /^(http[s]?:\/\/.*?\/[a-zA-Z-_]+.*)$/,
  
  ...
  var input = event.target.value // &lt;--- some string;
  var url   = input.match(this.urlRegex);
  </code></pre>
  
  <p>Problem is <code>url</code> returns the whole string when it finds a url, instead of returning just the part of the string matching the regex</p>
  
  <p>Example
  The string</p>
  
  <p><code>https://medium.com/aspen-ideas/there-s-no-blueprint-26f6a2fbb99c random stuff sd</code></p>
  
  <p>returns </p>
  
  <pre><code>["https://medium.com/aspen-ideas/there-s-no-blueprint-26f6a2fbb99c random stuff sd", "https://medium.com/aspen-ideas/there-s-no-blueprint-26f6a2fbb99c random stuff sd", index: 0, input: "https://medium.com/aspen-ideas/there-s-no-blueprint-26f6a2fbb99c random stuff sd"]
  </code></pre>
  
  <p>How can this be achieved?</p>