Your regular expression should look like this
<?php
$cedula = "18.842.389";
if(preg_match_all("/(\.d*[0-9]{2})/", $cedula, $resultado)){
print_r($resultado);
} else {
echo "No hubo resultado";
}
As notes, before the letter d and then from 0 to 9 it will verify that
just numbers we add the point; you do the test and with point
shows the array with the positions and if you remove them or put another
thing like middle guion shows you There was no result
But I need you to be with any special character
So instead of the point symbol you put \ W but it's capitalized and with that you validate that you enter between the figures special characters look
<?php
$cedula = "18.842.389";
if(preg_match_all("/(\W\d*[0-9]{2})/", $cedula, $resultado)){
print_r($resultado);
} else {
echo "No hubo resultado";
}
I leave you a list for special characters:
$ Match at the end of the string
\ s Match with any
White space
\ d Match with any digit
\ D Match
with any character other than a digit
\ w Match with
any character that can be part of a word (letter, number,
low script)
\ W Match with any character that CAN NOT be
part of a word (letter, number, underscore)
\ A Start of a
string.
\ z End of a string.