Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 884 Bytes

expandTabs.md

File metadata and controls

24 lines (19 loc) · 884 Bytes
title tags author_title author_url author_image_url description image
expandTabs
string,regexp,beginner
Deepak Vishwakarma
Implementation of "expandTabs" in typescript, javascript and deno.

JS TODO

Convert tabs to spaces, where each tab corresponds to count spaces.

Use String.prototype.replace() with a regular expression and String.prototype.repeat() to replace each tab character with count spaces.

const expandTabs = (str, count) => str.replace(/\t/g, " ".repeat(count));
expandTabs("\t\tlorem", 3); // '      lorem'