Precedence in regular expressions I'm having trouble finding the language represented by the following:

(AA|BB)*

Should the expression be read as... ( A (A|B) B ) *
or... ( (AA) | (BB) )*

If that isn't clear, should this produce something like... ABABAB or should it produce AABBAABBBBAA

My guess is that AABBAA is part of the represented language, while AB is not.
This depends entirely on convention; with respect to a (proper) formal definition, the expression is invalid as it not properly parenthesised. I'd say that typically, the order is (from stronger to weaker binding)


Kleene Star/Plus (also finite versions),
concatenation,
alternative.


Note that this corresponds (visually) to exponentiation over multiplication over addition in basic arithmetics, so it's probably the natural way.

That is,


$10^*1$ is read as $1(0)^*1$ and
$10|01|11$ as $(10)|(01)|(11)$.


Note that I still drop parentheses due to associativity of concatenation and alternative.