That doesn't really look right to me. In fact, your pattern will substitute more than 3 numbers: 5 7 8 11 12 becomes 3.
You could try this: regexp (5|6|7|8|11)\s(6|7|8|11)((\s(6|7|8|11|12))?) @substitute 3 which uses the ? operator to make the 3rd group optional. But then it won't match "11 12", for instance, since it requires a 5, 6, 7, 8,or 11 at the front of the potential list followed by a 6, 7, 8 or 11. So that regexp will match a minimum of 2 and a maximum of 3 numbers in a row.
Regular expressions can do nearly anything related to text processing, in fact, but like any other programming, you have to be really specific about the outcome you desire.