I'm currently removing spaces using a simple replace()
and adding a space that I must preserve between the third and fourth character using substr()
let str = 'abc defghijk lmnop qrstuv wx y z'
str = str.replace(/\s+/g, '')
// resultado: 'abcdefghijklmnopqrstuvwxyz'
str = str.substr(0, 3) + ' ' + str.substr(3, str.length)
console.log(str)
What is the most succinct way to get the same result using only the replace()
method?
PS: I really have little knowledge about using RegExp