title: How to match sth. "preceeded / followed by" something with regular expression?
body: <p>I am working with a Google Sheets document in which I need to manipulate strings and extract certain parts of them. These strings have exactly the following form, to the character:</p>
  
  <p><strong><em>Ad name: FOO_FOOBAR_DE_CH_Zagreb+N1_970x250.zip; 970x250</em></strong></p>
  
  <p>I need to extract two "fields":</p>
  
  <ul>
  <li>Zagreb</li>
  <li>970x250</li>
  </ul>
  
  <p>Obviously, the first one is always surrounded by <code>"\_"</code> and <code>"+"</code> which makes things a bit easier and the other one is either surrounded by <code>"_"</code> and <code>"."</code> OR preceded by <code>"; "</code> if I were to capture it from the end of the string.</p>
  
  <p>I am trying to use Google Sheets proprietary <code>REGEXMATCH</code> formula (<a href="https://support.google.com/docs/answer/3098292?hl=en" rel="nofollow">read more about it here</a>) but I must be doing something wrong. If it matters, Google products use <strong>RE2</strong> RegEx "flavor". </p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>=REGEXEXTRACT(text, "(?:_)[A-Za-z]+(?:\+).*")
  </code></pre>
  
  <p>This one returns:</p>
  
  <blockquote>
    <p>_Zagreb+</p>
  </blockquote>
  
  <p>so I need to lose the "_" and "+". I understand that for this type of operation (extracting text between certain characters) look-arounds should be used but I am still quite unfamiliar with these. Also, I understand that some of them (negative look-behind most notably) do not work with JavaScript.</p>
  
  <p>This is attempt 2:</p>
  
  <pre><code>=REGEXEXTRACT(text, ".*[A-Za-z]+(?=\+.*)")
  </code></pre>
  
  <p>This one just throws a <code>#REF</code> error. I find these two resources invaluable for learning RegEx:</p>
  
  <ul>
  <li><a href="http://rexegg.com" rel="nofollow">Rexegg</a></li>
  <li><a href="http://regular-expressions.info" rel="nofollow">Regular-expressions.info</a></li>
  </ul>
  
  <p>but since I am short of time, I can't afford to study this in detail right now.</p>