title: regex for extracting all urls from string excluding period for terminating strings
body: <p>I'm trying to extract URL from a piece of string I have different posts that contains URL in their message. I've prepared a pattern to match but it's not working properly. I have asked the same question <a href="https://stackoverflow.com/questions/48201777/regex-for-extracting-all-urls-from-string">here</a> but forgot to add this case in that so I'm asking a new question for it.</p>
  
  <p><strong>Tried Pattern</strong></p>
  
  <pre><code>\b(\.?)(?:https?://)?(?:(?i:[a-z]+\.)+)[^\s,]+\b
  </code></pre>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>for ( $i = 0; $i &lt; $resultcount; $i ++ ) {
      $pattern = '%\b(\.?)(?:https?://)?(?:(?i:[a-z]+\.)+)[^\s,]+\b%';
      $message = (string)$result[$i]['message'];
      preg_match_all($pattern,$message,$match);
      print_r($match);
      }
  </code></pre>
  
  <p>A Example of my post like this</p>
  
  <blockquote>
    <p>"This is just a post to test regex for extracting URL.
    <a href="http://google.com" rel="nofollow noreferrer">http://google.com</a>, <a href="https://www.youtube.com/watch?v=dlw32af" rel="nofollow noreferrer">https://www.youtube.com/watch?v=dlw32af</a>
    <a href="https://instagram.com/oscar/" rel="nofollow noreferrer">https://instagram.com/oscar/</a> en.wikipedia.org"</p>
  </blockquote>
  
  <p>Post may have comma or may not have comma for multiple URLs and also it is possible that a string and url doesn't have any space in between like </p>
  
  <blockquote>
    <p>sometext.<a href="http://google.com" rel="nofollow noreferrer">http://google.com</a></p>
  </blockquote>
  
  <p><a href="https://regex101.com/r/zueqmp/2" rel="nofollow noreferrer">regexDemo</a></p>
  
  <p>Thank you people :)</p>