Back to Home
$removeSplitTextElement
$removeSplitTextElement removes one element from the
current text split by its index. The remaining elements shift down to
fill the gap.
Syntax
$removeSplitTextElement[Index]
-
Index: the position of the element to remove. Must be a positive integer.
What happens
-
$textSplitcreates the split and stores the elements. -
$removeSplitTextElementremoves the element at the given index. -
All elements after it shift down by one (what was index
4becomes3, and so on). -
Nothing is returned, use
$joinSplitTextor$splitTextto work with the updated split.
Example 1: Remove the last element
$nomention
$textSplit[hello-world-!;-]
$removeSplitTextElement[3]
$joinSplitText[-]
What happens:
-
$textSplitcreateshello(1),world(2),!(3). -
$removeSplitTextElement[3]removes!. -
$joinSplitText[-]reassembles the remaining elements.
Output:
hello-world
Example 2: Remove a middle element
$nomention
$textSplit[a,b,c,d;,]
$removeSplitTextElement[2]
$joinSplitText[,]
What happens:
-
$textSplitcreatesa(1),b(2),c(3),d(4). -
$removeSplitTextElement[2]removesb.cshifts to index 2,dto index 3. -
$joinSplitText[,]rejoins the remaining elements.
Output:
a,c,d
Common uses
- Filtering out a value from a list before displaying it
- Stripping unwanted entries at the start or end of a split
-
Building modified lists before passing them to
$joinSplitText
See also
- $textSplit: must be called first to create the split
- $joinSplitText: to reassemble the split after removing an element
- $getTextSplitIndex: to find the index of a value before removing it
- $editSplitText: to replace an element instead of removing it