Answers for "regex used text and number only android"

0

regex used text and number only android

InputFilter filter = new InputFilter() { 
    public CharSequence filter(CharSequence source, int start,
                               int end, Spanned dest, int dstart, int dend) { 

        for (int i = start;i < end;i++) { 
            if (!Character.isLetterOrDigit(source.charAt(i)) && 
                !Character.toString(source.charAt(i)).equals("_") && 
                !Character.toString(source.charAt(i)).equals("-")) 
            { 
                return ""; 
            } 
        } 
        return null; 
    } 
}; 

edittext.setFilters(new InputFilter[] { filter });
Posted by: Guest on February-18-2021

Browse Popular Code Answers by Language