统计连续字母
$str = 'aabbcccddd' $reg = '/([a-z])1+/' preg_match_all($reg, $str, $match) $match => [ [ "aa", "bb", "ccc", "ddd", ], [ "a", "b", "c", "d", ], ] foreach($match[1] as $k => $v) { echo $v . strlen($match[0][$k]); } a2b2c3d3⏎
统计连续字母
$str = 'aabbcccddd' $reg = '/([a-z])1+/' preg_match_all($reg, $str, $match) $match => [ [ "aa", "bb", "ccc", "ddd", ], [ "a", "b", "c", "d", ], ] foreach($match[1] as $k => $v) { echo $v . strlen($match[0][$k]); } a2b2c3d3⏎