I would like to validate my infix notation through regex. Right now I have something like this:
^[a-zA-Z0-9_]+(( [a-zA-Z0-9_]+)|( [\+\-\/\*]))*( [a-zA-Z0-9_]+)$
I check if the expresion starts and ends with operands. In the middle i can have operands or operators always devided by single space. There could be only one operator and operands can have multiple characters. Everything seems to be ok for now. But I would also like to check if operands are always separated by operator and I have no idea how to achieve that. Could someone give me some advice?