# Replace space Full Name regex?

**URL:** <https://discourse.nodered.org/t/replace-space-full-name-regex/24112>\
**Category:** General\
**Created:** [2 April 2020 19:47 UTC](https://discourse.nodered.org/t/replace-space-full-name-regex/24112 "2020-04-02T19:47:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [2 April 2020 19:47 UTC](https://discourse.nodered.org/t/replace-space-full-name-regex/24112/1 "2020-04-02T19:47:45Z")

</div>

Hi.

Have tried to read about regex expressions but don't succeed. Maybe there is an easier way to do this.  
I want to replace the space between first name and surname in a payload with %20.

The payload is for example John Sander and I want the output to be John\*%20Sander

Anyone have an idea?

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [2 April 2020 20:06 UTC](https://discourse.nodered.org/t/replace-space-full-name-regex/24112/2 "2020-04-02T20:06:00Z")

</div>

```auto
msg.payload = msg.payload.replace(/\ /g, “%20”);

```

this should replace every space in the string.  
best regards Johannes

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [2 April 2020 21:31 UTC](https://discourse.nodered.org/t/replace-space-full-name-regex/24112/3 "2020-04-02T21:31:43Z")

</div>

I suspect what you are trying to do is make it into a uri - so the encodeURI function may just do what you want - and would work for other "odd" characters as well

````auto
msg.payload = encodeURI(msg.payload);
return msg;
```
````

---

<div class="post-metadata">

**Author:** ![niclas.w82](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/niclas.w82/32/31813_2.png) [@niclas.w82](https://discourse.nodered.org/u/niclas.w82)\
**Post date:** [3 April 2020 14:43 UTC](https://discourse.nodered.org/t/replace-space-full-name-regex/24112/4 "2020-04-03T14:43:06Z")

</div>

> [@dceejay](#):
>
> encodeURI

encodeURI Was a great solution!!  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [2 June 2020 14:43 UTC](https://discourse.nodered.org/t/replace-space-full-name-regex/24112/5 "2020-06-02T14:43:11Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
