JavaScript
22
Вклад в тег
<?php
$mask = 'abab';
$rgPattern = array(
'aaaa' => '/(\d)\1{3}/',
'aabb' => array(
'/(\d)\1(?!\1)([^\1])\2/',
'/(\d)\1([^\1])\2([^\1\2])\3/'
),
'abab' => array(
'/(\d)([^\1])(?:\1(?!\1)\2){1}/',
'/(\d)([^\1])\1\2\1\2/'
),
'aabbcc' => '/(\d)\1([^\1])\2([^\1\2])\3/',
'ababab' => '/(\d)([^\1])\1\2\1\2/',
'abcabc' => '/(\d)([^\1])([^\1\2])\1\2\3/'
);
$rgNum = array(9096223434, 9096660865, 9096225151);
$pattern = $rgPattern[$mask];
$result = array_filter($rgNum, function($num) use ($pattern) {
$num = preg_replace('/\D/', '', $num);
if(is_array($pattern)) {
return (preg_match($pattern[0], $num) && !preg_match($pattern[1], $num));
}
return !!preg_match($pattern, $num);
});
print_r($result);
$vibranye = array_filter($shiny, function (array $arr) use ($parametr_widther) {