统计连续字母

$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⏎

  

posted on 2019-09-07 15:39  jzfan  阅读(182)  评论(0编辑  收藏  举报