I have following code to replace left spaces with a specific string but, It is not working as I want.
console.log(' asdadasdad as asdasd asasd'.replace(/^s+/, 'x'))
This will surely do in two lines:
var str =' asdadasdad as asdasd asasd'; console.log(str.trim().padStart(str.length, 'x'));
2.1m questions
2.1m answers
60 comments
57.0k users