preg_match():
<?php
$str = "1978,Dérick,Rethans";
if (preg_match('@,(.{6}),@', $str, $result)) {
echo 'We matched: ', $result[1], "<br/>\n";
} else {
echo 'There was no match!', "<br/>\n";
}
?>
Output:
There was no match!
preg_match() in UTF-8 mode:
<?php
$str = "1978,Dérick,Rethans";
if (preg_match('@,(.{6}),@u', $str, $result)) {
echo 'We matched: ', $result[1], "<br/>\n";
} else {
echo 'There was no match!', "<br/>\n";
}
?>
Output:
We matched: Dérick