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