Regular expression for strings with an even number of zeroes and ones

后端 未结 4 1909
逝去的感伤
逝去的感伤 2021-01-12 08:06

What is a regular expression for strings of 0 and 1 with an even number of zeros and an even number of ones?

I have something like (1*01*01*)*(0*10*10*)*

4条回答
  •  遥遥无期
    2021-01-12 08:21

    Well, this is probably homework, but what the heck:

    ^(00|11|(01|10)(00|11)*(01|10))*$
    

    Edit: simplified!

提交回复
热议问题