title: Regex to find a string from last occurrence of a character to a number or [
body: <p>I have a text</p>
  <pre><code>Word_1 (string_2)! String_3 - String_4 X_1:X_2
  </code></pre>
  <p>where <code>String_2</code>, <code>String_3</code> and <code>String_4</code> can have one or multiple words (with numbers also, like <code>aaa b32</code>), while X_1 and X_2 can be a single digit number or a <code>[</code> (followed by a single digit number and a <code>]</code>, so something like <code>9:[4]</code> or <code>[9]:4</code>).</p>
  <p>And this regex (used inside an Android app) for matching String_4 (so the string between <code>- </code> and X_1:</p>
  <pre><code>(?&lt;=\-\s)[a-zA-Z0-9]+\s([a-zA-Z0-9]+\s)?
  </code></pre>
  <p>It works fine, but I've just realized that String_2 can also contains '- ' (for example <code>String_2 = aaa - bbb ccc</code>) so I need to fix my regex for starting from last occurrence of <code>- </code> (and again ending before X_1, considering that String_4 can have numbers as well).</p>
  <p>How to do that?</p>
  <p>I've tried <code>(?:[^\-](?!(\-)))+$</code> but I can't find a way for avoiding the <code> </code> after <code>-</code> and to stop at X_1.</p>
  <p>Thanks!</p>