I notice a derivative of this problem from other programming langauges.
If you want to remove multiple extra spaces then you can use 3 Replace() functions in a row to replace them with a single space.
If we set a parameter "newparam" to your example "Joplin Smith"
, we can use 3 replaces like so:
@replace(replace(replace(pipeline().parameters.newparam, ' ', ' %'), '% ', ''), '%', '')
Output after each replace:
1 - "value": "Joplin % % %Smith"
2 - "value": "Joplin %Smith"
3 - "value": "Joplin Smith"
At this point you can wrap the command with the split() function and it will only intercept single spaces:
@split(replace(replace(replace(pipeline().parameters.newparam, ' ', ' %'), '% ', ''), '%', '')
, ' ')
Produces the array:
"value": [
"Joplin",
"Smith"
]