RelativePosition.FromEnd (1) is an enumeration that indicates whether indexing should be done from the start or end of the input. It is a member of the RelativePosition.Type and specifies that indexing should be done from the end of the input. This is relevant for functions that retrieve text based on an the position of a delimiter in a string.
Examples
You can use the Relative Position enumeration to specify where indexing should start.
The Text.BeforeDelimiter function supports the optional index agument. It indicates which occurrence of the delimiter
should be considered, as well as whether indexing should be done from the start or end of the input.
= Text.BeforeDelimiter( "11-22-33-44", "-" ) // Returns "11"
= Text.BeforeDelimiter( "11-22-33-44", "-", { 0, RelativePosition.FromEnd } ) // Returns "11-22-33"
= Text.BeforeDelimiter( "11-22-33-44", "-", { 1, RelativePosition.FromEnd } ) // Returns "11-22"
= Text.BeforeDelimiter( "11-22-33-44", "-", { 2, RelativePosition.FromEnd } ) // Returns "11"
Text.AfterDelimiter works similarly, but then focuses on text after a delimiter.
= Text.AfterDelimiter( "x-87-33-v", "-" ) // Returns "87-33-v"
= Text.AfterDelimiter( "x-87-33-v", "-", { 0, RelativePosition.FromEnd } ) // Returns "v"
= Text.AfterDelimiter( "x-87-33-v", "-", { 1, RelativePosition.FromEnd } ) // Returns "33-v"
= Text.AfterDelimiter( "x-87-33-v", "-", { 2, RelativePosition.FromEnd } ) // Returns "x-87-33-v"
Lastly, you can provide the Text.BetweenDelimiters function with the Relative Position Type. You can provide instructions for both the starting index and the ending index.
= Text.BetweenDelimiters( "01-ab-99-p", "-", "-" ) // Returns "ab"
= Text.BetweenDelimiters( "01-ab-99-p", "-", "-", { 0, RelativePosition.FromEnd } ) // Returns "p"
= Text.BetweenDelimiters( "01-ab-99-p", "-", "-", { 1, RelativePosition.FromEnd } ) // Returns "99"
= Text.BetweenDelimiters( "01-ab-99-p", "-", "-", { 2, RelativePosition.FromEnd } ) // Returns "ab"
Related enumerations
Other related enumerations are:
Applies to
Here’s a list of functions that work with RelativePosition.Type:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy