Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
92
rated 0 times [  94] [ 2]  / answers: 1 / hits: 26549  / 7 Years ago, wed, august 2, 2017, 12:00:00

Given these two strings:



var a = November 5, 1916;
var b = October 5–10, 1592;


I am doing:



b.replace(' ', '').split(' ');
a.replace(' ', '').split(' ');


But I still get a comma and no white space. I need to be able to remove ALL commas from those strings and keep the white space in order to have:



var resultA = November 5 1916;
var resultB = October 5–10 1592;


update



I do need the split() afterwards as I need each string in an array.


More From » jquery

 Answers
2

The split() method is not needed since you are not trying to turn the string into an array.



Just to remove all commas straighforwardly:



a.replace(',', '');
b.replace(',', '');

[#56888] Monday, July 31, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
magdalena

Total Points: 364
Total Questions: 101
Total Answers: 92

Location: Namibia
Member since Mon, Nov 14, 2022
2 Years ago
;