Text.SplitAny
TextSplits a text value at any character found in the separators string, returning a list of substrings.
Syntax
Text.SplitAny(text as text, separators as text) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The text value to split. |
separators | text | Yes | A text value whose individual characters are each treated as a delimiter. |
Return Value
list — A list of text values split at any occurrence of any character in separators.
Remarks
Text.SplitAny splits text at every occurrence of any character found in the separators string. Each character in separators is treated as an independent single-character delimiter — not as a multi-character substring to match. This is the key difference from Text.Split, which treats the entire second argument as one delimiter.
For example, Text.SplitAny("a,b;c", ",;") splits on both , and ; independently, producing {"a", "b", "c"}. In contrast, Text.Split("a,b;c", ",;") would look for the exact two-character sequence ",;" and return the original string unsplit if that sequence does not appear.
Consecutive separator characters produce empty strings in the result list. If your source data may have multiple consecutive separators (such as double spaces or mixed delimiters), filter the result with List.Select(result, each _ <> "") to remove empty entries.
A notable application of Text.SplitAny is collapsing internal spaces: Text.Combine(Text.SplitAny(text, " "), " ") splits on spaces and rejoins with a single space, effectively collapsing runs of multiple spaces. Text.Trim alone does not remove internal duplicate spaces — this pattern is the standard workaround.
Examples
Example 1: Split on multiple delimiter characters
Text.SplitAny("East,West;North", ",;")Result | |
|---|---|
| 1 | East,West,North |
Example 2: Normalize multiple internal spaces in a name
Text.Combine(Text.SplitAny("alice smith", " "), " ")Result | |
|---|---|
| 1 | alice smith |
Example 3: Split a path that uses mixed separators
Text.SplitAny("C:/Users\\Kyle/Documents", "/\\")Result | |
|---|---|
| 1 | C:,Users,Kyle,Documents |
Example 4: Filter empty entries produced by consecutive separators
let
raw = "Sales,,East,,Q1",
parts = Text.SplitAny(raw, ","),
nonEmpty = List.Select(parts, each _ <> "")
in
nonEmptyThe final output — filters the list with List.Select to remove all empty strings, leaving only the three non-empty segments.
Result | |
|---|---|
| 1 | Sales,East,Q1 |