@ 2016-01-07T17:45:36Z <?php
$rows = [
['`1234567890-=', '~!@#$%^&*()_+'],
['qwertyuiop[]\\', 'QWERTYUIOP{}|'],
['asdfghjkl;\'', 'ASDFGHJKL:"'],
['zxcvbnm,./', 'ZXCVBNM<>?']
];
$wholeregex = [];
foreach($rows as $k => $row) {
$num = $k + 1;
echo "Row $num\n";
$array = [];
foreach($row as $subrow) {
$subarray = array_map('ord', str_split($subrow));
$array = array_merge($subarray, $array);
}
sort($array);
echo "\t" . implode( ' ', $array), "\n";
$ret = [$array[0]];
for($i = 1; $i < count($array); $i++) {
$num = $array[$i];
if(($array[$i - 1] + 1) == $num) {
if( ($i == (count($array) - 1)) || ($array[$i + 1] != ($num + 1)) ) {
$ret[] = array_pop($ret) . '-' . $num;
}
} else {
$ret[] = $num;
}
}
echo "\t" . implode( ' ', $ret), "\n";
$regex = '([';
$subregex = implode( '', array_map(function($el) {
$vals = explode('-', $el);
if(count($vals) == 1) {
return chr($vals[0]);
}
return chr($vals[0]) . '-' . chr($vals[1]);
}, $ret));
$regex .= $subregex;
$regex .= '])';
echo "\t" . $regex, "\n";
$wholeregex[] = $regex;
}
$finalregex = '%' . implode('|', $wholeregex) . '%';
$finalregex = str_replace('(-', '\(-', $finalregex);
echo $finalregex, "\n";
echo strlen($finalregex), "\n";
$argv[1] = "a";
$i=$argv[1];preg_match("%([!#-&\(-+-0-9=@^-`~])|([EIO-RT-UWY[-]eio-rt-uwy{-}])|(["':-;ADF-HJ-LSadf-hj-ls])|([,.-/<>-?B-CM-NVXZb-cm-nvxz])%",$i,$m);echo array_flip($m)[$i];
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.2 Parse error: syntax error, unexpected '':-;ADF-HJ-LSadf-hj-ls])|([,.-' (T_ENCAPSED_AND_WHITESPACE), expecting ',' or ')' in /in/cP7IT on line 59
Process exited with code 255 . Output for 5.5.24 - 5.5.31 , 5.6.8 - 5.6.17 Parse error: syntax error, unexpected '':-;ADF-HJ-LSadf-hj-ls])|([,.-' (T_ENCAPSED_AND_WHITESPACE) in /in/cP7IT on line 59
Process exited with code 255 . preferences:dark mode live preview
176.95 ms | 1395 KiB | 28 Q