Your solution will void condition 3. It will ensure only a
subchain. For example, it will match 1abab
which does not contain aa
. Here's one which I have found working:
1a(a[1ab]*|[1ab]*aa[1ab]*)
This begins with 1a. Then based on whether the next character is a (as in 1aa, which will satisfy all 3 conditions btw), searches for any combination of 1, a and b or any combination with an aa
in it.
Note: In your notation of formal language, the given regex be like:
1a((a(1+a+b)*)+((1+a+b)*aa(1+a+b)*))