How do I replace multiple characters with the same number of characters with a regular expression?

后端 未结 3 1804
旧巷少年郎
旧巷少年郎 2021-01-20 23:58

I\'ve got the following source:

011011000010011011&         


        
3条回答
  •  一整个雨季
    2021-01-21 00:27

    $test = '0110110000100110110110';
    
    echo preg_replace ('~()([10]*)()~e', '"\\1" . str_repeat(" ", strlen ("\\2")) . "\\3"', $test);
    

提交回复
热议问题