# Removing spaces from variables

**URL:** <https://community.postman.com/t/removing-spaces-from-variables/38853>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [September 5, 2022, 12:04pm UTC](https://community.postman.com/t/removing-spaces-from-variables/38853 "2022-09-05T12:04:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alathorn](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@alathorn](https://community.postman.com/u/alathorn)\
**Post date:** [September 5, 2022, 12:04pm UTC](https://community.postman.com/t/removing-spaces-from-variables/38853/1 "2022-09-05T12:04:04Z")

</div>

Hello, how can I replace a character in a collection variable? I have to pass value from first request to another.

Response value of the first request is a string, always with the same format of 2 letters followed by space and random number (letters and numbers are random) e.g.:

`"key": "XX 233"`

I set a collecion variable by using:

```auto
const jsonData = pm.response.json();
pm.collectionVariables.set("test_var", jsonData.key);

```

The next request requires this variable in format “XX233”, so I have to get rid of space in the string. I’m new to Postman, so I hope I’m asking in a correct category.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [September 5, 2022, 1:08pm UTC](https://community.postman.com/t/removing-spaces-from-variables/38853/2 "2022-09-05T13:08:01Z")

</div>

Postman uses JavaScript under hood.

Have a look at the following;

> **[Remove All Whitespace From a String in JavaScript](https://futurestud.io/tutorials/remove-all-whitespace-from-a-string-in-javascript)**
>
> Future Studio provides on-demand learning & wants you to become a better Android (Retrofit, Gson, Glide, Picasso) and Node.js/hapi developer!

---

<div class="post-metadata">

**Author:** ![alathorn](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@alathorn](https://community.postman.com/u/alathorn)\
**Post date:** [September 6, 2022, 6:57am UTC](https://community.postman.com/t/removing-spaces-from-variables/38853/3 "2022-09-06T06:57:29Z")

</div>

Great, it’s working, thanks
