>

Wednesday, March 19, 2014

Remove String in Numbers-Java Program

public String removeStringInNumbers(String str) {
        String temp = "";
        String regexp = "^[a-zA-Z]";
        Pattern pattern = Pattern.compile(regexp);
        Matcher matcher;
        if(!str.isEmpty()){
        for (int i = 0; i < str.length(); i++) {
            matcher = pattern.matcher(str.charAt(i) + "");
            if (!matcher.matches()) {
                temp = temp + str.charAt(i) + "";
            }
        }}
        System.out.println("" + temp);
        return temp;
    }

No comments:

Post a Comment

Please post your comments. Your comments make us to write more programs for you.