title: Hive find last occurrence
body: <p>My apologies if there is an answer somewhere else.</p>
  
  <p>I have a string stored in a Hive field that can have 0 to n occurrences of '&amp;' followed by text after each occurrence.  </p>
  
  <p>In Hive, I would like to find the final occurrence and grab all the text after that occurrence.</p>
  
  <p>Using ...</p>
  
  <pre><code>split(field1,'[&amp;]')[n]
  </code></pre>
  
  <p>... I can grab the nth occurence, but I cannot predict the final or count backwards.  </p>
  
  <p>I was able to get the following to work:</p>
  
  <pre><code>reverse(split(reverse(field1),'[&amp;]')[0])
  </code></pre>
  
  <p>However, using three functions seems like a lot of unnecessary overhead.  I know that you can use regex in regexp_extract(), but I am confounded by regex.</p>
  
  <p>Would regexp_extract() be faster and how would this be accomplished?</p>