title: How to extract everything until first occurrence of pattern
body: <p>I'm trying to use the <a href="https://github.com/tidyverse/stringr" rel="noreferrer">stringr</a> package in R to extract everything from a string up until the first occurrence of an underscore.</p>
  <p><strong>What I've tried</strong></p>
  <pre><code>str_extract(&quot;L0_123_abc&quot;, &quot;.+?(?&lt;=_)&quot;)
  &gt; &quot;L0_&quot;
  </code></pre>
  <p>Close but no cigar.  How do I get this one?  Also, Ideally I'd like something that's easy to extend so that I can get the information in between the 1st and 2nd underscore and get the information after the 2nd underscore.</p>