# how to describe this regular expression in English

I am trying to describe regular expression in English here,

and let's say we have for (b(bb)*)*

you would say: zero or more b's

or we can have (a(aa)*b(bb)*)*

you would say: odd number of a's that end in odd number of b's

now my question is about ((a+b)a)*

you would say: words of even length where every even letter is an 'a'

where did the even length come from ??? how did they get every even letter is an 'a' ? is it from the zero a's because zero is an even number ?

## Answers

((a+b)a)*

*"you would say: words of even length where every even letter is an 'a'"*

This is not a correct description. More accurate would be "words that have *at least one a*, followed by *exactly one b*, followed by *exactly one a*, zero or more times"

(+ means "one or more", * means "zero or more".)

It's more about the back and forth of as and bs--there could be million as between the bs, but there's never two bs next to each other.

And note that the inner parenthesis are not needed. In other words, this is equivalent:

(a+ba)*

Free spaced:

(a+ //"a", one or more times b //followed by exactly one "b" a //followed by exactly one "a" )* //zero or more times

The only way your description is accurate is if you interpret the expression a+b as a or b. Most regular expression tools write this using a vertical bar, as in a|b. The other commenters and answerers have interpreted the + as a postfix operator meaning "one or more".

Using that reading, the reason every string in this set must be of even length is because the repetition comes outside a string of length 2. It means "zero or more copies of either aa or ba". Clearly every word matching that description is of even length. 0 is even by definition, and every second letter has to be an a.

{ ยข, aa, ba, aaaa, aaba, baaa, baba, ... }