OpenBI Docs Buy

Text.BetweenDelimiters

The part of a text between a start delimiter and the end delimiter that follows it.

Group: Text and characters. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Text.BetweenDelimiters(text as nullable text, startDelimiter as text, endDelimiter as text, optional startIndex as any, optional endIndex as any) as any
ParameterTypeDescription
textnullable textThe text to work on; null gives null.
startDelimitertextThe text that opens the part you want.
endDelimitertextThe text that closes it.
startIndexany
optional
Which start delimiter to use, from 0; or {index, RelativePosition.FromEnd}. Left out, the first.
endIndexany
optional
Which end delimiter after the start one to use, from 0; or {index, RelativePosition.FromEnd}. Left out, the first.

Returns

any. The text between the two delimiters; empty when the start delimiter isn't there.

Remarks

  • The end delimiter is looked for only after the start delimiter, so the same character may open and close the part (quotes, for example).

Examples

An order code in brackets

Text.BetweenDelimiters("Order [A-1001] shipped", "[", "]")
"A-1001"

The second pair of parentheses

Text.BetweenDelimiters("Chair (oak) and desk (pine)", "(", ")", 1, 0)
"pine"

Start index 1 is the second opening parenthesis; end index 0 the first closing one after it.

Text.AfterDelimiter, Text.BeforeDelimiter, Text.Middle.

Last updated · OpenBI Studio 0.3.79