fork download
  1. <?php
  2. $re = "/(\\w+)(?=\\s+\\d)/m";
  3. $str = "width 40cm height 70cm\nwidth: 40cm height 70cm";
  4.  
  5. $result = preg_replace($re, "$1:", $str);
  6. print_r($result);
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
width: 40cm height: 70cm
width: 40cm height: 70cm