# Remove spaces between words

**URL:** <https://forum.dynamobim.com/t/remove-spaces-between-words/16201>\
**Category:** Revit\
**Created:** [November 3, 2017, 1:24pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201 "2017-11-03T13:24:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 1:24pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/1 "2017-11-03T13:24:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [November 3, 2017, 1:27pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/2 "2017-11-03T13:27:24Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/4/2490e7ba02a4f287cfe8429a0736f9e277eb2f80.png)

Essentially replace space`" "` with nothing `""`

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 1:36pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/3 "2017-11-03T13:36:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [November 3, 2017, 1:37pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/4 "2017-11-03T13:37:22Z")

</div>

> [@BIMadmin](#):
>
> keep just one

What do you mean? You can separate strings by spaces.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/d/8db5298ea694c367c562888692cdc17bf8317d47.png)

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

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 1:41pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/5 "2017-11-03T13:41:05Z")

</div>

that exactly Nick!

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 1:42pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/6 "2017-11-03T13:42:13Z")

</div>

keep only one space in the string between words

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 1:48pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/7 "2017-11-03T13:48:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 3, 2017, 2:02pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/8 "2017-11-03T14:02:23Z")

</div>

Just take a look at the Dictionary by typing “trim” or “slice” or “split”, it could give you some clues to get started:  
[http://dictionary.dynamobim.com/#/Core/String/Action/TrimLeadingWhitespace](http://dictionary.dynamobim.com/#/Core/String/Action/TrimLeadingWhitespace)  
See also what’s in the Primer about strings:  
[http://dynamoprimer.com/en/04\_The-Building-Blocks-of-Programs/4-4\_strings.html](http://dynamoprimer.com/en/04_The-Building-Blocks-of-Programs/4-4_strings.html)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [November 3, 2017, 2:12pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/9 "2017-11-03T14:12:36Z")

</div>

Python would also work really well for this.  
[https://stackoverflow.com/questions/1546226/a-simple-way-to-remove-multiple-spaces-in-a-string-in-python](https://stackoverflow.com/questions/1546226/a-simple-way-to-remove-multiple-spaces-in-a-string-in-python)

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 3, 2017, 2:18pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/10 "2017-11-03T14:18:44Z")

</div>

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

> [@Split, strip and join again](https://forum.dynamobim.com/t/split-strip-and-join-again/7860/6):
>
> You can use regex with the following pattern \S\*\s-\s like shown in this post:

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

> [@Remove characters of items](https://forum.dynamobim.com/t/remove-characters-of-items/5783):
>
> Hi everyone, Can anyone tell me how to remove some characters of string? For example, I have an item “thickness default 150mm” and I’d like to remain 150 for calculation in next steps. Thank you in advance

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 2:41pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/11 "2017-11-03T14:41:07Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 3, 2017, 2:43pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/12 "2017-11-03T14:43:27Z")

</div>

> [@BIMadmin](#):
>
> Can anyone drop the graph here please?

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

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 2:51pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/13 "2017-11-03T14:51:17Z")

</div>

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

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/4/e4dfa97f74a10f63e6dac3cd0dc98bb5155bb39e.JPG)  
I have copied the code into a python script node in dynamo but no luck,  
Image attached ![python script](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/6/16f305d93d852644954112752b8aef6043137995.JPG) ![Capture1](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/a/9a5c9c035e2bfb2176663dd517e2cf43fff26d2c.JPG)

---

<div class="post-metadata">

**Author:** ![Yna\_Db](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/yna_db/32/30641_2.png) [@Yna\_Db](https://forum.dynamobim.com/u/Yna_Db)\
**Post date:** [November 3, 2017, 2:55pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/14 "2017-11-03T14:55:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 2:59pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/15 "2017-11-03T14:59:23Z")

</div>

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

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/2/12d00057768f5ba36dd9de98fde748c05c204c9f.JPG)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [November 3, 2017, 3:00pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/16 "2017-11-03T15:00:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 3:46pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/17 "2017-11-03T15:46:50Z")

</div>

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

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/b/bba25be30124b0b424f4b77fb8623ac495a76c42.JPG)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [November 3, 2017, 3:50pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/18 "2017-11-03T15:50:35Z")

</div>

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.)

---

<div class="post-metadata">

**Author:** ![BIMadmin](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@BIMadmin](https://forum.dynamobim.com/u/BIMadmin)\
**Post date:** [November 3, 2017, 4:02pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/19 "2017-11-03T16:02:07Z")

</div>

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

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/0/40575f609b0c8743b7a1d37dac1f131083495515.JPG)[Trim spaces sheet name.dyn](https://forum.dynamobim.com/uploads/short-url/hrISQWxJIguojoH17CGizc44BiL.dyn) (6.6 KB)

---

<div class="post-metadata">

**Author:** ![skakub](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@skakub](https://forum.dynamobim.com/u/skakub)\
**Post date:** [April 11, 2018, 4:58pm UTC](https://forum.dynamobim.com/t/remove-spaces-between-words/16201/20 "2018-04-11T16:58:50Z")

</div>

… 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!
