$re = '/^[01]*(?=.*?1.*1)(?=.*?0.*0).{4}$/m';
$str = '001100
000000
000011
0011
1001
0110
0000
1111
1110
0101
1010
110000000000000111111111111111110000110
1100000000000001111111111111111100001';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php