Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
0|1 需要正则表达式,但字母不能重复。
所以:
101010 - valid 010101 - valid 110011 - invalid
好吧,这很简单:
(?=[01])0?(?:10)*1?
1?(01)*0? // matches alternating 1s and 0s ^1?(01)*0?$ // same as above but only whole strings