问题
I want to match item id,looks like:
a1234...
b5678...
c9876...
...
How can I write a regex only match first five characters
and first is alphabet letter, 2-5 is integer number
回答1:
preg_match_all('/[a-z]\d{2,5}/', $subject, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[0]); $i++) {
# Matched text = $result[0][$i];
}
来源:https://stackoverflow.com/questions/17512890/php-preg-match-item-first-five-character-regex