Splitter.SplitTextByWhitespace
SplitterReturns a splitter function that splits text on whitespace characters, with optional CSV quoting behavior.
Syntax
Splitter.SplitTextByWhitespace(optional quoteStyle as nullable number) as functionParameters
| Name | Type | Required | Description |
|---|---|---|---|
quoteStyle | number | No | Controls how quoted strings containing whitespace are handled. Use QuoteStyle.None (default) or QuoteStyle.Csv to preserve whitespace within double-quoted segments. |
Return Value
function — A function that splits text at whitespace boundaries.
Remarks
Splitter.SplitTextByWhitespace returns a splitter function that divides text at sequences of whitespace characters (spaces, tabs, and other Unicode whitespace). Multiple consecutive whitespace characters are treated as a single separator, and leading/trailing whitespace does not produce empty strings at the start or end.
The optional quoteStyle parameter controls whether content within double quotes is preserved as a single token even if it contains whitespace. Passing QuoteStyle.Csv enables CSV-style quoting, where "Hello World" is treated as a single token.
This splitter is commonly used with Table.SplitColumn to tokenize space-separated values or normalize inconsistently spaced data.
Examples
Example 1: Split on whitespace
Splitter.SplitTextByWhitespace()("Hello World Power Query")Result | |
|---|---|
| 1 | Hello,World,Power,Query |
Example 2: Leading and trailing whitespace produces no empty elements
Splitter.SplitTextByWhitespace()(" apple banana ")Result | |
|---|---|
| 1 | apple,banana |
Example 3: Preserve quoted tokens with CSV quote style
Splitter.SplitTextByWhitespace(QuoteStyle.Csv)("one ""two words"" three")Result | |
|---|---|
| 1 | one,two words,three |
Example 4: Use with Table.SplitColumn
Table.SplitColumn(
#table({"Tags"}, {{"alpha beta gamma"}}),
"Tags",
Splitter.SplitTextByWhitespace()
)Tags.1 | Tags.2 | Tags.3 | |
|---|---|---|---|
| 1 | alpha | beta | gamma |