 <p>Your looking for: <code>substring(REF from '([0-9]+(-| )([A-Za-z]\y)?)')</code></p> <p>In <a href="http://www.sqlfiddle.com/#!15/d41d8/496/1" rel="nofollow">SQLFiddle</a>. Your primary problem is that <code>substring</code> returns the first or outermost matching group (ie., pattern surrounded with <code>()</code>), which is why you get 50 for your '50-R'. If you were to surround the entire pattern with <code>()</code>, this would give you '50-R'. However, the pattern you have fails to return what you want on the other strings, even after accounting for this issue, so I had to modify the entire regex.</p>