@ 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.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.2 0.027 0.083 20.24 7.0.1 0.007 0.067 20.33 7.0.0 0.000 0.057 20.20 5.6.17 0.023 0.033 20.47 5.6.16 0.010 0.040 20.43 5.6.15 0.010 0.073 18.13 5.6.14 0.003 0.050 18.24 5.6.13 0.013 0.057 18.21 5.6.12 0.013 0.077 21.06 5.6.11 0.000 0.047 21.03 5.6.10 0.010 0.080 21.15 5.6.9 0.000 0.093 21.14 5.6.8 0.013 0.040 20.52 5.5.31 0.027 0.053 20.25 5.5.30 0.003 0.080 18.08 5.5.29 0.007 0.060 18.09 5.5.28 0.010 0.077 20.98 5.5.27 0.007 0.047 20.78 5.5.26 0.007 0.077 20.96 5.5.25 0.013 0.040 20.63 5.5.24 0.027 0.050 20.14
preferences:dark mode live preview
164.25 ms | 1394 KiB | 7 Q