improve callback serial number regex (#6435)

Adds S/N and Serial Num/number
This commit is contained in:
Tony Murray
2017-04-16 01:42:22 -05:00
committed by Neil Lathwood
parent 924b751be4
commit 2f881e3d80

View File

@@ -85,19 +85,16 @@ if ($enabled == 1) {
}, $entry['sysDescr']);
// wipe serial numbers, preserve the format
$entry['sysDescr'] = preg_replace_callback('/(SN[:=]? ?)([A-Za-z0-9.\-]{4,16})/', function ($matches) {
$patterns = array(
'/[A-Z]/',
'/[a-z]/',
'/[0-9]/'
);
$replacements = array(
'A',
'a',
'0'
);
return $matches[1] . preg_replace($patterns, $replacements, $matches[2]);
}, $entry['sysDescr']);
$sn_patterns = array('/[A-Z]/', '/[a-z]/', '/[0-9]/');
$sn_replacements = array('A', 'a', '0');
$entry['sysDescr'] = preg_replace_callback(
'/((s\/?n|serial num(ber)?)[:=]? ?)([a-z0-9.\-]{4,16})/i',
function ($matches) use ($sn_patterns, $sn_replacements) {
return $matches[1] . preg_replace($sn_patterns, $sn_replacements, $matches[4]);
},
$entry['sysDescr']
);
return $entry;
}, $device_info);