spaces_to_tabs

string

Converts sequences of spaces to tab characters

Syntax

spaces_to_tabs(string)

Parameters

string (string)

The string to convert

Returns

string

String with space sequences replaced by tabs

Examples

Input:
spaces_to_tabs("hello    world")
Output:
"hello\tworld"
Input:
"a    b" | spaces_to_tabs
Output:
"a\tb"

The spaces_to_tabs() function converts sequences of spaces to tab characters. Typically converts a standard number of spaces (usually 4) to a single tab.

Usage

Use spaces_to_tabs() for converting indentation to tabs, reducing file size, or standardizing code formatting to tab-based indentation.

Related Functions