RelativePosition.FromStart

RelativePosition.FromStart (0) 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 start of the input. This is relevant for functions that retrieve text based on an the position of a delimiter in a string.

Examples

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.FromStart } ) // Returns "11"
= Text.BeforeDelimiter( "11-22-33-44", "-", { 1, RelativePosition.FromStart } ) // Returns "11-22"
= Text.BeforeDelimiter( "11-22-33-44", "-", { 2, RelativePosition.FromStart } ) // Returns "11-22-33"

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.FromStart } ) // Returns "87-33-v"
= Text.AfterDelimiter( "x-87-33-v", "-", { 1, RelativePosition.FromStart } ) // Returns "33-v"
= Text.AfterDelimiter( "x-87-33-v", "-", { 2, RelativePosition.FromStart } ) // Returns "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.FromStart } ) // Returns "ab"
= Text.BetweenDelimiters( "01-ab-99-p", "-", "-", { 1, RelativePosition.FromStart } ) // Returns "99"
= Text.BetweenDelimiters( "01-ab-99-p", "-", "-", { 2, RelativePosition.FromStart } ) // Returns "p"

Other related enumerations are:

Applies to

Here’s a list of functions that work with RelativePosition.Type:

BI Gorilla Youtube Channel

Last update: August 17, 2023 | Contribute » | Contributors: Rick de Groot
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.