1// =======( /.{4}/g ) Replace number 4 number the any the number for cout the char
2// this will add space after each charactar
3// ========= (index % 40 == 36 ? '\n' : ' ') spose you have 100 characater thrn
4//this line will add new line after each 40 character..
5
6
7var replaced = str.replace(/.{4}/g, function (value, index) {
8 return value + (index % 40 == 36 ? '\n' : ' ');
9});