UTF-8 , \d [[:digit:]], ASCII. -ASCII-, Unicode, \p{Nd}:
$s = "12345\xD9\xA1\xD9\xA2\xD9\xA3\xD9\xA4\xD9\xA5";
preg_match_all('~\p{Nd}{5}~u', $s, $matches);
ideone.com
If you need to match specific characters or ranges, you can use the escape sequence \x{HHHH}with the corresponding code points:
preg_match_all('~[\x{0661}-\x{0665}]{5}~u', $s, $matches);
... or use the form \xHHto enter UTF-8 encoded byte sequences:
preg_match_all("~[\xD9\xA1-\xD9\xA5]{5}~u", $s, $matches);
Note that for the last example, I switched to double quotes. Form \p{}and \x{}were transferred for processing by the compiler regex, but this time we want to PHP compiler extended escape-sequence. This does not occur in single quotes.
source
share