Regular Expressions: Class 2
Regular Expressions: Class 2
Class 2
Obtain regular expressions for the
following
●
Strings of a’s and b’s having length 2
(aa + ba + ab + bb)
(a + b)(a + b)
●
Strings of a’s and b’s having length ≤ 2
(Ɛ + a + b)2
●
Strings of a’s and b’s having length ≤ 10
(Ɛ + a + b)10
●
Strings of a’s and b’s having even length
((a + b)(a + b))*
●
Strings of a’s and b’s having odd length
(a + b)((a + b)(a + b))*
●
Strings of a’s and b’s having alternate a’s and
b’s
(Ɛ + b)(ab)*(Ɛ + a)
●
Strings of a’s and b’s starting with a and ending
with b
a(a + b)*b
●
Strings of a’s and b’s whose second symbol from
right end is a
(a + b)*a(a + b)
●
Strings of a’s and b’s whose tenth symbol from
right end is a
(a + b)*a(a + b)9
●
Strings of 0’s and 1’s with at most one pair of
consecutive 0’s
1* + (1 + 01)*0(1 + 10)* + (1 + 01)*00(1 + 10)*
●
Strings containing at least one a and atleast
one b where Σ = {a, b, c}
(a + b + c)*a(a + b + c)*b(a + b + c)* +
(a + b + c)*b(a + b + c)*a(a + b + c)*
●
Strings of 0’s and 1’s with at least three
consecutive 0’s
(0 + 1)*000(0 + 1)*
●
Strings of a’s and b’s ending with b and has no
substring aa
(b + ab)(b + ab)*
●
Strings of 0’s and 1’s having no two consecutive
zeros
(1 + 01)*(0 + Ɛ)