remove a hyphen from string in jquery

Posted by Klbaiju under jQuery on 3/20/2015 | Points: 10 | Views : 489 | Status : [Member] | Replies : 1
I want to replace a hyphen from a string

var b = "20-March-2015";

var s = b.replace(/-/g, '')

iam gettting the output as 20March2015.

but i need like this 20 March 2015 means a space instead of hyphen.

how it possible.


Posted by: Jitendrasoft09 on: 3/21/2015 [Member] [MVP] Starter | Points: 25


Replace function has parameters to replace char. Try with following code-
var b = "20-March-2015";
var k = s.replace("-", " ");
var s = b.replace("-", " ");

Jitendra Kumar
If my post helps you, plz mark as an answer.

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response