Splitter.SplitTextByCharacterTransition
SplitterReturns a function that splits text at transitions between character types.
Syntax
Splitter.SplitTextByCharacterTransition(before as anynonnull, after as anynonnull) as functionParameters
| Name | Type | Required | Description |
|---|---|---|---|
before | anynonnull | Yes | A character classification function or list of characters. The split occurs where a character matching before is followed by a character matching after. |
after | anynonnull | Yes | A character classification function or list of characters. The split occurs where a character matching before is followed by a character matching after. |
Return Value
function — A 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 classes as lists of characters, such as {"a".."z", "A".."Z"} for letters and {"0".."9"} for digits, or as functions that take a single character and return true or false. M has no built-in functions that classify characters as letters or digits, so you build these lists yourself.
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({"a".."z", "A".."Z"}, {"0".."9"}),
Parts = SplitFn("WidgetA100")
in
#table({"TextPart", "NumberPart"}, {{Parts{0}, Parts{1}}})The final output — a table with the alphabetic prefix in TextPart and the numeric suffix in NumberPart.
TextPart | NumberPart | |
|---|---|---|
| 1 | WidgetA | 100 |