First translate to an english description of the language:
(a U b)*(a U e)b* U (a U b)*(b U e)a*
Translates to:
Any sequence of a
s or b
s, followed by an optional a
, followed by any number of b
s.
OR
Any number of a
s and b
s, followed by an optional b
, follwed by any number of a
s
There is a lot of overlap here - at least (a U b)*(a U e)
is exactly the same as (a U b)*
, because "Any sequence of a
s and b
s" necessarily either ends with an a
or epsilon (as any string can end with epsilon) so those groups can be eliminated, leaving
(a U b)*b* U (a U b)*a*
Translates to:
Any sequence of a
s or b
s, followed by any number of b
s.
OR
Any number of a
s and b
s, follwed by any number of a
s
Now the first section of those to outermost groups is the same, so lets collapse those into one
(a U b)*(a* U b*)
Translates to:
Any sequence of a
s or b
s, followed by any number of a
s OR by any number b
s.
now hold on a minute, "Any sequence of As and Bs" necessarily ends with "Any sequence of a
s OR any sequence of b
s", which means anything which matches the first part can match the whole regex (because the second part can have a length of zero) so why don't we just make it
(a U b)*
Ta Da. Simple.