title: regular expression to find word after a character and before another one if included
body: <p>I have a url like:</p>
  
  <blockquote>
    <p>image/media-group/rugby-league-programme-covers-3436?sort=title</p>
  </blockquote>
  
  <p>or</p>
  
  <blockquote>
    <p>image/media-group/rugby-league-programme-covers-3436</p>
  </blockquote>
  
  <p>I need to get everything after media-group and not including <code>?</code> or anything after.</p>
  
  <p>So in both instances <code>rugby-league-programme-covers-3436</code> is what I need to return</p>
  
  <p>I used the regular expression <code>/media-group/(.*)\?</code> which works for the instance where there is a query string but not in the instance where there is no query string.</p>
  
  <p>I am using the below code</p>
  
  <pre><code>var patt=new RegExp('/media-group/(.*)\?');
  return patt.exec(url)[1];
  </code></pre>
  
  <p>Your help on this would be most appreciated </p>