Reputation: 491
Can some one help with defining a regex for language L while strings in L don't contain 101 as a substring? (if only 0s and 1s are allowed)
I already have (1|0)*[^(101)]
but it does reject all the strings in the language.
Upvotes: 2
Views: 54
Reputation: 785991
Add this negative lookahead:
^(?!.*?101)[01]+$
in front of your regex.
Upvotes: 2