title: RegEx for matching URLs in Python
body: <p>I have this example string:</p>
  
  <pre><code>line = '[text] something - https://www.myurl.com/test1/ lorem ipsum https://www.myurl.com/test2/ - https://www.myurl.com/test3/ marker needle - some more text at the end'
  </code></pre>
  
  <p>I need to extract the path (without slashes) before "marker needle". The following works to list all paths:</p>
  
  <pre><code>print re.findall('https://www\\.myurl\\.com/(.+?)/', line)
  # ['test1', 'test2', 'test3']
  </code></pre>
  
  <p>However, when I change it to only find the path I want (the one before "marker needle"), it gives a weird output:</p>
  
  <pre><code>print re.findall('https://www\\.myurl\\.com/(.+?)/ marker needle', line)
  # ['test1/ lorem ipsum https://www.myurl.com/test2/ - https://www.myurl.com/test3']
  </code></pre>
  
  <p>My expected output:</p>
  
  <pre><code>test3
  </code></pre>
  
  <p>I have tried the same with <code>re.search</code> but the result is the same.</p>