Text.BetweenDelimiters
Text.BetweenDelimiters
Syntax
Text.BetweenDelimiters(
text as text,
startDelimiter as text,
endDelimiter as text,
optional startIndex as any,
optional endIndex as any
) as any
Remarks
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
.
Examples
Example #1
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)", "(", ")")
Result:
"222"
Example #2
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)
Result:
"444"
Example #3
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})
Result:
"222) 333 (444"
Category
Text.Transformations