DEV Community

Discussion on: 1 line of code: How to convert spaces to tabs

Collapse
 
lexlohr profile image
Alex Lohr

This is still converting tabs to spaces, not the other way around, as advertised.

const spacesToTabs = (input, length = 4) => input.replace(new RegExp(` {${length}}`, 'g'), '\t');
Enter fullscreen mode Exit fullscreen mode
Collapse
 
martinkr profile image
Martin Krause

Hi Alex,

thank you for pointing this out. Classic copy & paste error.

I updated the code and the article with my originally inteded code.

Cheers!