Regular Expressions 1-29 Flashcards
What does λ mean?
Empty String
What does + mean?
Or
What does * mean?
any number of ( including zero )
r = (λ + a)
Either a single a or nothing
r = a*
Any number of a’s including no a’s
r = (a + b)* (a + bb)
Any string of a’s and b’s ending in either a ‘a’ or ‘bb’
r = (aa)* (bb)* b
Any zero or even number of a’s followed by an odd number of b’s
Create a regular expression for:
L(r) = {w ∈ {0, 1}* : w has no consecutive zeros}
r = (1 + 01)* (0 + λ)
A language that accepts any odd number of b’s
(bb)*b
An odd number of a’s followed by a single b
(aa)*ab
A string of 0’s and 1’s that contains at least one 0 and one 1
(0+1)(01+10)(0+1)
A string of 0’s and 1’s with no consecutive 0’s or 1’s
(0+λ)(10)(1+λ) she said this technically works even though it’s odd
(bb)(aa)
An even number of b’s followed by an even number of a’s
01*0
0 followed by any number of 1’s followed by another 0
ab(ab)
a followed by any number of b’s followed by any number of ab’s