I have edittext in a form, I want that when the user inputs text into the edittext for my program to detect which language was inserted into the edittext.
Is there a
You can know a string is english or persian by using Regex.
public static final Pattern VALID_NAME_PATTERN_REGEX = Pattern.compile("[a-zA-Z_0-9]+$");
public static boolean isEnglishWord(String string) {
return VALID_NAME_PATTERN_REGEX.matcher(string).find();
}
this only works with words and numbers. if there is a character like '=' or '+' , the function would return false . you can fix that by editing the regex to match what you need .