Text.RemoveRange
TextRemoves a specified number of characters from a text value starting at the given offset.
Syntax
Text.RemoveRange(text as nullable text, offset as number, optional count as nullable number) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The original text value. |
offset | number | Yes | The zero-based position at which to begin removing characters. |
count | number | No | The number of characters to remove. If omitted or null, all characters from offset to the end are removed. |
Return Value
text — A new text value with the specified characters removed.
Remarks
Text.RemoveRange removes count characters from text beginning at the zero-based offset position. The characters before offset and after offset + count are concatenated to form the result. The original string is not modified — a new value is returned.
If text is null, the function returns null. If count is omitted or null, all characters from offset to the end of the string are removed. If count extends beyond the length of the string, all characters from offset onward are removed without error.
This is equivalent to: Text.Start(text, offset) & Text.End(text, Text.Length(text) - offset - count)
Use Text.RemoveRange for positional removal — when you know the exact character position and length of the content to remove. If you want to remove by content (all occurrences of a substring), use Text.Replace(text, toRemove, ""). If you want to replace removed characters with new content rather than nothing, use Text.ReplaceRange.
Examples
Example 2: Remove a separator character at a known position
Text.RemoveRange("(555) 123-4567", 0, 1)Result | |
|---|---|
| 1 | 555) 123-4567 |
Example 3: Remove everything from an offset to the end
Text.RemoveRange("Sales Rep - East Region", 9)Result | |
|---|---|
| 1 | Sales Rep |
Example 4: Remove an internal segment from a formatted string
Text.RemoveRange("Widget-East-001", 6, 5)Result | |
|---|---|
| 1 | Widget-001 |