Tuesday 2 February 2016

Regular expression to replace alphanumeric with ?

public class RegEx {

        public static void main(String str1[]){
            String str="a1SS233,32332ss21233,3233221dd233,323322ff1233," +
                    "3233221233,S3233221233,3233221233D,3233221233,323322,";
            str = str.replaceAll("[0-9 a-z A-Z]+", "?");

            System.out.println(str);
        }
}
 
output : 
 
?,?,?,?,?,?,?,?,?,