tags:

views:

90

answers:

2

Please help me construct a regex to match:

some text(x, x, x, x)

where x can be any integer either positive or negative.

I need it to match exactly as it is shown above. Each x can be a different positive or negative integer.

+3  A: 

Try something like this:

[^(]+\(\s*-?\d+(\s*,\s*-?\d){3}\s*\)
Mark Byers
+1  A: 

that exactly would be /text((-?\d+,?){,3})/

or more generally /^\w+((-?\d+,?)+)/

Mimisbrunnr
matches text(12 48 38 58). I suggest something like this: /^\w+\(-?\d+(,?\s*\d+){3}\)/
Benson