Replace space Full Name regex?


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?

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

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

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

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

encodeURI Was a great solution!!
Thanks a lot

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