Regular replacement of symbols in the middle of dates

var p_strDate="2006-10-18 18:01:00";
var pattenStr = new RegExp("\s| |_|[-]|/|:","g");
var arrPatten = p_strDate.replace(pattenStr,'');
alert(arrPatten);
undefined
var p_strDate="2006---____-10-18     18:::01::00";
var pattenStr = new RegExp("\s| |_|[-]|/|:","g");
var arrPatten = p_strDate.replace(pattenStr,'');
alert(arrPatten);



var p_strDate="2006---____-10-18     18:::01::00";
var arrPatten = p_strDate.replace(/\s|-|:/g,'');
alert(arrPatten);



var p_strDate="2006---____-10-18     18:::01::00";
var pattenStr = new RegExp(" |_|[-]|/|:","g");
var arrPatten = p_strDate.replace(pattenStr,'');
alert(arrPatten);



I hope my experience of entering the pit is helpful to you, may the Holy Light be with you

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324350008&siteId=291194637