0% found this document useful (0 votes)
27 views6 pages

Regular Expressions: Class 2

The document provides regular expressions for strings consisting of the symbols a and b with various conditions on length and patterns. Some examples of regular expressions given are (a + b)(a + b) for strings of length 2, (a + b)*a(a + b) for strings where the second symbol from the right end is an a, and (0 + 1)*000(0 + 1)* for strings of 0s and 1s with at least three consecutive 0s. A total of 14 different regular expressions for strings with conditions on symbols are listed.

Uploaded by

Apoorva Naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views6 pages

Regular Expressions: Class 2

The document provides regular expressions for strings consisting of the symbols a and b with various conditions on length and patterns. Some examples of regular expressions given are (a + b)(a + b) for strings of length 2, (a + b)*a(a + b) for strings where the second symbol from the right end is an a, and (0 + 1)*000(0 + 1)* for strings of 0s and 1s with at least three consecutive 0s. A total of 14 different regular expressions for strings with conditions on symbols are listed.

Uploaded by

Apoorva Naik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Regular Expressions

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 + Ɛ)

You might also like