How to insert space after every two letters in string with Node.js

1 Answer

0 votes
let str = 'nodejsjavaccphpc++';
 
str = str.replace(/.{1,2}(?=(.{2})+$)/g, '$& ');

console.log(str); 
 
    
    
    
    
/*
run:
    
no de js ja va cc ph pc ++

*/

 



answered Apr 26, 2022 by avibootz

Related questions

...