# Remove hyphen in between 2 words (Solved)

**URL:** <https://forum.wixstudio.com/t/remove-hyphen-in-between-2-words-solved/20049>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [January 23, 2018, 7:20am UTC](https://forum.wixstudio.com/t/remove-hyphen-in-between-2-words-solved/20049 "2018-01-23T07:20:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgcbooking](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/sgcbooking/32/857_2.png) [@sgcbooking](https://forum.wixstudio.com/u/sgcbooking)\
**Post date:** [January 23, 2018, 7:20am UTC](https://forum.wixstudio.com/t/remove-hyphen-in-between-2-words-solved/20049/1 "2018-01-23T07:20:44Z")

</div>

I use the WixLocation API to identify first and last names of the current user in a dynamic page [  
let lastName = wixLocation.path[1];  
let firstName = wixLocation.path[2];  
]  
and then proceed with some additional features. It works perfectly with one exception:  
When the user has a double first or double last names (let’s suppose his first name is Jean Baptiste), then the wixLocation.path[1] gives jean-baptiste with a hyphen in the middle. And it then prevents all of my next additional features.  
Is there any way I can remove this hyphen in between these two names?

Thanks for yoru reply.

---

<div class="post-metadata">

**Author:** ![admin-23](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/admin-23/32/708_2.png) [@admin-23](https://forum.wixstudio.com/u/admin-23)\
**Post date:** [January 23, 2018, 1:52pm UTC](https://forum.wixstudio.com/t/remove-hyphen-in-between-2-words-solved/20049/2 "2018-01-23T13:52:48Z")

</div>

Hi,

A URL cannot contain the whitespace character, therefore a hyphen is added as a filler character  
You can use a loop to iterate the string characters and replace any hyphens with a whitespace character.

---

<div class="post-metadata">

**Author:** ![sgcbooking](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/sgcbooking/32/857_2.png) [@sgcbooking](https://forum.wixstudio.com/u/sgcbooking)\
**Post date:** [January 24, 2018, 3:39am UTC](https://forum.wixstudio.com/t/remove-hyphen-in-between-2-words-solved/20049/3 "2018-01-24T03:39:42Z")

</div>

Hi Ido,  
Can you kindly be a bit more explicit? How can I identify 1st, 2nd, … letters in a string? And replace the hyphen with a white space? Which tool from which API do I need?  
Thanks,

---

<div class="post-metadata">

**Author:** ![sgcbooking](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/sgcbooking/32/857_2.png) [@sgcbooking](https://forum.wixstudio.com/u/sgcbooking)\
**Post date:** [January 24, 2018, 8:56am UTC](https://forum.wixstudio.com/t/remove-hyphen-in-between-2-words-solved/20049/4 "2018-01-24T08:56:33Z")

</div>

Issue solved.

let lastN = wixLocation.path[1];  
var lastName = lastN.replace(/-/g, ’ ');
