$_='~1~,,~234~,7,~,,~,8'; s/(~\d\d*~)(,,)/\1,~~,/g; ~1~,~~,~234~,7,~,,~,8