Remove spaces between words

Hello community,
I am sure this is a very easy operation but I am not sure how to do it?
I would like to remove spaces between words, only keep one.
Is there a node that do this?

Essentially replace space" " with nothing ""

1 Like

Hi John,
Thanks for your answer, but what if we need to keep just one?
we can use a conditional statement with a number of possibilities but I dont think this is a smart way, is it?

What do you mean? You can separate strings by spaces.

EDIT: Or do you mean you have excess spaces between words and you need to reduce them down to a single space?

1 Like

that exactly Nick!

keep only one space in the string between words

in excel there is one operation called trim, I just need the same here in dynamo.
Is there an easy way?

Just take a look at the Dictionary by typing “trim” or “slice” or “split”, it could give you some clues to get started:
See also what’s in the Primer about strings:

Python would also work really well for this.

Nice, I add it to my favourites, along with this one:

Edit: I just found another good one on this topic:

Hello guys,
Sorry for my ignorance, I am new in dynamo and not familiar with python out of the box node editor.
Can anyone drop the graph here please?
Thank you very much in advance, you are amazing!

We usually would rather take a look at what you have tried and answer the particular issues you encounter in doing it :slightly_smiling_face:

1 Like

I have tried with all the nodes that you suggested in the dynamo primer, but none works.
Image attached

I have copied the code into a python script node in dynamo but no luck,
Image attached

Is it normal that the sheet names list is empty in your first graph?

it isn’t I just did not run in the image that I attached here,
see another shot

String.Split gets you half way there. You just need to join your strings again with a single space.

Thank you very much Nick, really appreciated
it seems to be working fine in dynamo but my sheet name in Revit is not changing,
do you know why, please see image attached

Your String.Join node is giving you a sublist of names. You need to Flatten those values before setting the parameter for each sheet. (You can see all the names are being applied to the same sheet.)


Amazing Nick, thank you very much for your help, you are a star!!!
Share graph just in case need it.

Trim spaces sheet name.dyn (6.6 KB)

1 Like

… The exact solution helped me as well: in order to have a multi-line text as room name, i had to add spaces. Then for scheduling, I’ve added a text-based instance parameter to room, which populates with the room name minus the spaces. Long story short, thank you @Nick_Boyts for the solution!