$str = 'abc123';
preg_match('#([a-z]*)(\d*)#', $str, $match);
echo 'alpha: ' . $match[1];
echo 'num: ' . $match[2];?>
The # is pattern delimiter. It marks start and end of the pattern, and you can choose any from a bunch of characters for this.
[] denotes a character class. in this case, any characters maching the characters a through z. If you also want to get uppercase letters, you'd need to use either [a-zA-Z] or end the pattern with #i. The part after the ending delimiter is pattern modifier, and the i stands for case insensitive.
\d matches a decimal digit.
- matches one or more characters. So [a-z]* matches zero or more lower case letters.
() marks a subpattern, which is capturing by default. (?🙂 marks a non capturing subpattern. The capturing subpatterns are put into $match[1], $match[n], where n is the number of capturing subpatterns. $match[0] holds the complete pattern match.