var str = "abcdefghijklmnopqrstuvwxyz"; var reg = /(.{17})(.*)/; str = str.replace(reg, "$1 xxx,$2");