Thursday 19 May 2016

string function

String userInput = "Hello, World! ssss1££$$%%##";
    //    String onlyAlphaNumeric = userInput.replaceAll("[^a-zA-
Z0-9]", "");
       
        //only num
    //String onlyAlphaNumeric = userInput.replaceAll("[^0-9]", "");
        //num and alpabets
                String onlyAlphaNumeric = userInput.replaceAll("[^a-zA-Z0-9]", "");           
        System.out.println(onlyAlphaNumeric);

No comments:

Post a Comment