Mooh
Mooh

Reputation: 1247

describing a language with a regular expression

How can i write a regular expression to describe this language : enter image description here

Upvotes: 1

Views: 524

Answers (2)

Sören
Sören

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

SLaks
SLaks

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

Related Questions