Splitter.SplitTextByCharacterTransition

Splitter

Returns a function that splits text at transitions between character types.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Splitter.SplitTextByCharacterTransition(before as anynonnull, after as anynonnull) as function

Parameters

NameTypeRequiredDescription
beforeanynonnullYesA character classification function or list of characters. The split occurs where a character matching before is followed by a character matching after.
afteranynonnullYesA character classification function or list of characters. The split occurs where a character matching before is followed by a character matching after.

Return Value

functionA function that takes a text value and returns a list of text parts split where the character type transitions from before to after.

Remarks

Splitter.SplitTextByCharacterTransition returns a function that splits text at the boundary where one character type transitions to another. You specify the before and after character classifications using functions like Character.IsLetter and Character.IsNumber, or by providing lists of characters.

This is especially useful for splitting strings that combine letters and digits without a delimiter — for example, splitting "ABC123" into "ABC" and "123".

Examples

Example 1: Split where letters transition to digits

let
    SplitFn = Splitter.SplitTextByCharacterTransition(Character.IsLetter, Character.IsNumber),
    Parts = SplitFn("WidgetA100")
in
    #table({"TextPart", "NumberPart"}, {{Parts{0}, Parts{1}}})
Result
TextPart
NumberPart
1WidgetA100

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks