Answers for "javascript split text after x characters"

0

javascript split text after x characters

// =======( /.{4}/g  ) Replace number 4 number the any the number for cout the char 
// this will add space after each charactar  
// ========= (index % 40 == 36 ? '\n' : ' ') spose you have 100 characater thrn
//this line will add new line after each 40 character..


var replaced = str.replace(/.{4}/g, function (value, index) {
    return value + (index % 40 == 36 ? '\n' : ' ');
});
Posted by: Guest on August-19-2021

Code answers related to "javascript split text after x characters"

Code answers related to "Javascript"

Browse Popular Code Answers by Language