Это сделает то, что вам нужно:
<?php
$a = 's1234';
$b = 'S2345';
$c = 'S234A';
function checkthe($pattern) {
if($pattern[0] !== 'S') { return 'Failed'; }
elseif (!ctype_digit(substr($pattern, 1, 4))) { return 'Failed'; }
else { return 'Success'; }
}
echo checkthe($a) . "<br />\n";
echo checkthe($b) . "<br />\n";
echo checkthe($c) . "<br />\n";
?>
Если вам нужно Regex:
<?php
$regex = '/S{1}\d\d\d\d/m';
$str = 'S1234
s4224
S2222
';
preg_match_all($regex, $str, $matches, PREG_SET_ORDER, 0);
var_dump($matches);
?>
OR:
<input type="text" name="statuscode" id="statuscode" minlenght="5" maxlenght="5" pattern="/S{1}\d\d\d\d/m"/>
Протестируйте здесь: https://regex101.com/r/B4sDGw/1