<p>Let's say I have a line of text like this</p>

<pre><code>Small   0.0..20.0   0.00    1.49    25.71   41.05   12.31   0.00    80.56
</code></pre>

<p>I want to capture the last six numbers and ignore the <em>Small</em> and the first two groups of numbers.</p>

<p>For this exercise, let's ignore the fact that it might be easier to just do some sort of string-split instead of a regular expression.</p>

<p>I have this regex that works but is kind of horrible looking</p>

<pre><code>^(Small).*?[0-9.]+.*?[0-9.]+.*?([0-9.]+).*?([0-9.]+).*?([0-9.]+).*?([0-9.]+).*?([0-9.]+).*?([0-9.]+)
</code></pre>

<p>Is there some way to compact that?</p>

<p>For example, is it possible to combine the check for the last 6 numbers into a single statement that still stores the results as 6 separate group matches?</p>

If you want to keep each match in a separate backreference, you have no choice but to "spell it out" - if you use repetition, you can either catch all six groups "as one" or only the last one, depending on where you put the capturing parentheses. So no, it's not possible to compact the regex and still keep all six individual matches.
A somewhat more efficient (though not beautiful) regex would be:
```
```
^Small\s+[0-9.]+\s+[0-9.]+\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)
```
```
since it matches the spaces explicitly. Your regex will result in a lot of backtracking. My regex matches in 28 steps, yours in 106.
Just as an aside: In Python, you could simply do a
```
```
>>> pieces = "Small   0.0..20.0   0.00    1.49    25.71   41.05   12.31   0.00    80.56".split()[-6:]
>>> print pieces
['1.49', '25.71', '41.05', '12.31', '0.00', '80.56']
```
```