Frage

I need to find a Regular Expression for L consists of all strings with at most two occurrences of the string 00 over the alphabet E = {0,1}.

For example, 000 in L but 0000 not.

I tried to find it but I could not find it.Do you have any ideas?

Thanks in advance.

War es hilfreich?

Lösung

The following should work (where e is the empty string):

(1|01)* (e|0|00|000|001(1|01)*00) (1|10)*

Whenever you have to solve a problem with regular expressions and have a condition saying "at most ...blah blah blah," you normally just have to list all the possibilities.

Andere Tipps

It's the inverse of 00.*00

echo "000" | grep -v "00.*00"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top