Regular expression for all strings with at least one a

Write a Regular expressions defined over {a, b} for all strings with at least one a.

(a + b)* a (a + b)*

Valid strings: (must be accepted by our Regular Expression)

Strings of length 1: a, No other valid strings

Strings of length 2: aa, ab, ba, bb, No other valid strings

Strings of length 3: aaa, aab, baa, bab, No other valid strings

 Strings of length 4: aaaa, babb, aaab, baaa,……. and many other similar strings.

Strings of length 5: aaaab, aaaba, aaabb, abbba, aabaa, bbbaa,………and many other similar strings.

Note: Many other strings of lengths 6, 7, 8. 9, 10 11, ….etc which must have at least one a are valid. You can try it by yourself.

Invalid strings: (must be Rejected by our Regular Expression

Strings of length 1: b, No other invalid strings

Strings of length 2: bb, No other invalid strings

Strings of length 3: bbb, No other invalid strings

Note: All other strings defined over {a, b) that have no a are invalid strings. You can try it by yourself.

Write a Regular expressions defined over {0, 1} for all non empty strings of odd length.

(0 + 1)* 0 (0 + 1)*