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, ... }


Need Your Help

Is it possible to test an app on a device (ipad/iphone) without having the device connected?

iphone testing device deployment

This is NOT a question about avoiding to pay apple, my boss has no problem paying the $99 enrolling fee to do the signing certificate stuff. Jailbreaking is not an option.

Exception When Registering Lisst Change Listener

java exception generics user-interface javafx

I just added this code to my list program and I got an exception from it. I'm not exactly sure what is happening, and it avoided my efforts to debug with it. Specifically, the exception happened on...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.