Power Query
published
Search
⌃K

Text.BetweenDelimiters

Text.BetweenDelimiters

Text.BetweenDelimiters
function (optional text as nullable any, startDelimiter as text, endDelimiter as text, optional startIndex as nullable any, optional endIndex as nullable any) as nullable any

Description

Returns the portion of text between the specified startDelimiter and endDelimiter. An optional numeric startIndex indicates which occurrence of the startDelimiter should be considered. An optional list startIndex indicates which occurrence of the startDelimiter should be considered, as well as whether indexing should be done from the start or end of the input. The endIndex is similar, except that indexing is done relative to the startIndex.

Category

Text.Transformations

Examples

Get the portion of "111 (222) 333 (444)" between the (first) open parenthesis and the (first) closed parenthesis that follows it.
Text.BetweenDelimiters("111 (222) 333 (444)", "(", ")")
"222"
Get the portion of "111 (222) 333 (444)" between the second open parenthesis and the first closed parenthesis that follows it.
Text.BetweenDelimiters("111 (222) 333 (444)", "(", ")", 1, 0)
"444"
Get the portion of "111 (222) 333 (444)" between the second open parenthesis from the end and the second closed parenthesis that follows it.
Text.BetweenDelimiters("111 (222) 333 (444)", "(", ")", {1, RelativePosition.FromEnd}, {1, RelativePosition.FromStart})
"222) 333 (444"