문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

It's the inverse of 00.*00

echo "000" | grep -v "00.*00"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top