var str = "ABCdeaadsa12348dA D/+"; var reUp = new RegExp(/^[A-Z]+$/); var reDown = new RegExp(/^[a-z]+$/); var reNum = new RegExp(/^[0-9]+$/); var strUpperCase = new Array(); var strDownCase = new Array(); var strNum = new Array(); var strOther = new Array(); var newStr = new Array(); for(var i = 0; i < str.length; i++) { if(reUp.test(str[i])) { // strUpperCase.splice(i, 0, str[i]); strUpperCase.push(str[i]); console.log(strUpperCase); } else if(reDown.test(str[i])) { // strDownCase.splice(i, 0, str[i]); strDownCase.push(str[i]); console.log(strDownCase); } else if(reNum.test(str[i])) { // strNum.splice(i, 0, str[i]); strNum.push(str[i]); console.log(strNum); } else { // strOther.splice(i, 0 , str[i]); strOther.push(str[i]); } } strOther.concat(strUpperCase, strDownCase, strNum);