String s1= "[23, 56 ,21,22, 9,?\/]"; String s2 = s1.replaceAll("[\[\]\s?/\\]", ""); System.out.println(s2);//23,56,21,22,9,