Here’s how to split text into roughly equal lengths without breaking up whole words.
Setup
Your magic formula
Output
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.
-
Click on each imported module and save it. You may need to remap some variables.
Modules JSON Export
{
"subflows": [
{
"flow": [
{
"id": 49,
"module": "util:SetVariable2",
"version": 1,
"parameters": {},
"mapper": {
"name": "Split_Text",
"scope": "roundtrip",
"value": "{{add(emptyarray; join(slice(split(48.value; space); 0; floor(length(split(48.value; space)) / 2)); space); join(slice(split(48.value; space); floor(length(split(48.value; space)) / 2)); space))}}"
},
"metadata": {
"designer": {
"x": -1213,
"y": -586
},
"restore": {
"expect": {
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "name",
"type": "text",
"label": "Variable name",
"required": true
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
},
{
"name": "value",
"type": "any",
"label": "Variable value"
}
],
"interface": [
{
"name": "Split_Text",
"label": "Split_Text",
"type": "any"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}