Regular Expressions Excercises
Regular Expressions Excercises
1 regular expressions
a) All strings of lowercase letters that begin and end in a
a([a-z]*a)?
a[a-z]* | [a-z]*a
nonzero = 1 | 2 | ... | 9
digit = 0 | nonzero
answer = 0 | nonzero digit*
INF 5110
27/01/15 1
Exercise 2.1 regular expressions
f) All strings of a’s and b’s that contain no three consecutive b’s
(a | ba | bba)* (ε | b | bb)
INF 5110
27/01/15 2
g) All strings of a’s and b’s that contain an odd number of a’s and an odd number of
b’s
b*ab*(ab*ab*)* | a*ba*(ba*ba*)*
h) All strings of a’s and b’s with an even number of a’s and an even number of
(aa | bb)* ( (ab | ba) (aa | bb)* (ab | ba) (aa | bb)* )*
INF 5110
27/01/15 3