title: In regex, match either the end of the string or a specific character
body: <p>I have a string. The end is different, such as <code>index.php?test=1&amp;list=UL</code> or <code>index.php?list=UL&amp;more=1</code>. The one thing I'm looking for is <code>&amp;list=</code>.</p>
  
  <p>How can I match it, whether it's in the middle of the string or it's at the end? So far I've got <code>[&amp;|\?]list=.*?([&amp;|$])</code>, but the <code>([&amp;|$])</code> part doesn't actually work; I'm trying to use that to match either <code>&amp;</code> or the end of the string, but the end of the string part doesn't work, so this pattern matches the second example but not the first.</p>