Reputation: 1247
How can i write a regular expression to describe this language :
Upvotes: 1
Views: 524
Reputation: 2741
the following should do the job:
[0-1]{2}([0-1]{5})*
you first take 0 or 1 twice and then you add a block of five characters (0 or 1) an arbitrary number of times
Upvotes: 1
Reputation: 888087
You're trying to build a regex which matches zero or more occurences of (five [01]
s), followed by two more [01]
s.
In other words: ([0-1]{5})*[01]{2}
Upvotes: 1