Skip to content
Rodrigo Celso de Lima Porto edited this page Jan 13, 2026 · 1 revision

Splits a text into a list of substrings based on a regular expression pattern.

Syntax

Text.RegexSplit(
    textToSplit as text,
    regexPattern as text,
    optional caseInsensitive as logical,
    optional multiline as logical
) as list

Parameters

  • textToSplit: The input text to be split.
  • regexPattern: The regular expression pattern to use as the delimiter for splitting.
  • caseInsensitive (optional): A logical value indicating whether the regex matching should be case insensitive. Default is false.
  • multiline (optional): A logical value indicating whether to treat the input text as multiline. Default is false.

Return Value

Returns a list of substrings obtained by splitting the input text at each match of the regex pattern.

Remarks

  • Uses .NET regular expressions for pattern matching.
  • Due to Power Query's JavaScript parser limitations, some advanced regex features like lookbehind '(?<=pattern)' and negative lookbehind '(?<!pattern)' and certain flags (s, u, v, d, y) are not supported.
  • Only the flags i, m are available.

Examples

Example 1: Splits text by comma.

Text.RegexSplit("apple,banana,cherry", ",")

Result

{"apple", "banana", "cherry"}

Example 2: Splits text by any digit.

Text.RegexSplit("one1two2three3", "\d")

Result

{"one", "two", "three", ""}

Example 3: Splits text by any line feed.

Text.RegexSplit("Hello\nWorld", "\n", false, true)

Result

{"Hello", "World"}

Clone this wiki locally