How about this:
([+-]?\d[+-]?)+
which means "one or more digits, each of which may be preceded or followed by an additional plus or minus."
Here's a Python script test:
import re TESTS = "234654 24-3+-2 -234 25485+ ++--+".split() for test in TESTS: print test, ":", re.match(r'([+-]?\d[+-]?)+', test) is not None
which prints this:
234654 : True 24-3+-2 : True -234 : True 25485+ : True ++--+ : False
Richiehindle
source share