Slice variable
Keep part of a variable's text or list, by position.
In both apps
WarpX Browser
WarpX Phone
Slice variable cuts a variable down to a range of positions: characters of a text, or items of a list. The variable is overwritten with the part you keep. Use it to strip a fixed prefix or keep the first few results.
Settings
- Variable name
The variable to cut. It is replaced with the slice.
ExampleorderRef- Start index
Tick Start index and type the position to start from. Positions count from 0, and a negative number counts back from the end. It is ticked by default.
Example9- End index
Tick End index and type the position to stop before. That position is not included. Left unticked, the slice runs to the end.
Example14
Every block also has the shared block settings — a description, Disable block and what to do on an error. Fields that take text accept data from earlier blocks.
What it hands on
Overwrites the variable with the slice and hands the slice on as {{prevBlockData}}.
Example: Keep only the number in an order reference
- Start
- Open URL
- Get text
- Slice variable
- Insert data
- Read
ORD-2026-58213-VNinto a variable with Get text and Assign to variable, namedorderRef. - Add Slice variable and type
orderRefin Variable name. - Tick Start index and type
9. Tick End index and type14. - Run it.
orderRefis now58213.
Good to know
- If the variable does not exist, or holds something that cannot be sliced such as a number, the block changes nothing and raises no error.
- A value inserted as
58213is stored as a number, not text, and is then left as it is. - The indexes are plain numbers. References are not filled in there, nor in the variable name.
- For a variable whose name starts with
$$, only this run's copy changes.
See also
- RegEx variable — Replace a text variable with what a regular expression matches, or with a replaced version.
- Increase variable — Add a number to a variable, such as a counter.
- Insert data — Set variables and add values to the workflow's table, several at once.