I am trying to write a Regular Expression to read real literals based on this graph:
I found that this solution works:
([0-9]+(\.[0-9]+)?[Ee][\+\-]?[0-9]+)|([0-9]+\.[0-9]+)
Notice the two parts separated via alternation:
([0-9]+(\.[0-9]+)?[Ee][\+\-]?[0-9]+)
([0-9]+\.[0-9]+)
When I tried to switch the order of which one is on which side of the alternation symbol, it stops working
([0-9]+\.[0-9]+)|([0-9]+(\.[0-9]+)?[Ee][\+\-]?[0-9]+)
These parts are exactly the same as above, but now it's suddenly not working. Am I misunderstanding how the | (alternation) symbol works? Is it not the same as || (or) for boolean expressions?