Could you please try this pattern:

`#\\(([0-9]++)(?:,\\s*([0-9]++))?\\)#`

It seems to be more efficient