Valid:
((int)10)
(int)10
((char)((x+y)&1))
((int *)1)
Invalid:
Adding to aioobe's answer:
Looks like you're trying to write an expression parser. As already said in the other answer it is not possible using a regex. You should consider using an expression parser such as JEP or write one yourself using javacc.