Regex to detect numbers at start of string.
I have a string, consisting of: some numbers, a single letter, some numbers and letters.
F开发者_JAVA技巧or example: 987342j34kj3
I want to output something like:
$numbers = 987342
$letter = j
$restofit = 34kj3
Any idea how to do this with PHP? Can I use preg_match?
No problem:
preg_match('/(\d+)([a-z])([a-z0-9]+)/', $string, $matches);
// First element of $matches is the entire matched string, ignore it
list(, $numbers, $letter, $restofit) = $matches;
精彩评论