var str='20180625T070000'; alert(str.replace(/(\d{4})(\d\d)(\d\d\S\d\d)(\d\d)(\d\d)/,'$1-$2-$3:$4:$5'));