I am using replace method of string,
var text = this ex is not working.;
text = text.replace(" ", "+");
alert(text);
and got alert :
this+ex is not working.
Whats the problem here?
Try this: lil diff demo http://jsfiddle.net/bLaZu/6/
Please note:
The g flag on the RegExp, it will make the replacement globally within the string.
If you keen: https://developer.mozilla.org/en/JavaScript/Guide/Regular_Expressions
Rest feel free to play around with demo, :)
code
var text = "this ex is not working.";
text = text.replace(/\s+/g, '+');
alert(text);
:)