Mix all ingredient and cook for long time.

	
I want to replace all the occurances of a period (.) in a JavaScript string

For example, I have:

var mystring = 'okay.this.is.a.string';
I want to get: okay this is a string.

So far I tried:

mystring.replace(/./g,' ')
but this ends up with all the string replaced to spaces.

Any idea how to resolve this?

javascript string replace
share|improve this question
edited Nov 13 '12 at 12:03

Paul D. Waite
23.1k854123	
asked Mar 6 '10 at 0:10

Omar Abid
2,43322954
4	  
aefxx's answer is correct, but just as an FYI is that the period character in a regex means match everything, thus everything being a space. Escaping it with the backslash means match on periods. – swilliams Jul 27 '10 at 16:52
Thanks for the tip. I have has some AHA moments (when building the app) with Regex. I really hate it _, do you have some cool, good tutorial? – Omar Abid Jul 31 '10 at 1:32
rubular.com is what you're looking for – LanguagesNamedAfterCofee Jul 17 '12 at 15:41

Sheetal
