title: How to write hive regex to match condition 1 OR condition 2 and return whichever matches?
body: <p>I need to have "or" logic in my regexp.</p>
  
  <ol>
  <li>For example, from "foobar435" I would need the three numbers, so "435"</li>
  <li>But from "barfoo543" I would need the three letters before the three numbers, so "foo"</li>
  </ol>
  
  <p>Individually, the regexes would be "foobar([0-9]){3}" to get the first case, and "[a-zA-Z]{3}([0-9]{3})[a-zA-Z]{3}" to get the second case.  How do I get both cases at once with one regexp?  So, if the first regexp matches then return "435", but if not, return "foo"?</p>
  
  <p>I am using hive so ideally I want to make one call only.  So far I have...</p>
  
  <pre><code>REGEXP_EXTRACT(myString, 'foobar([0-9]){3}', 1) AS columnName
  </code></pre>
  
  <p>Not sure how to add the second case into this.  Thanks!</p>