Am just trying to write a method in java that will use regular expression to check if a word does not contain any repeated letter whether "AAA" or "Aba" or "aa" and does not include any special characters like $, !, &, ....
Here is what I tried so far.
public boolean checkWord(String word) {
Pattern regex = Pattern.compile("([a-zA-Z0-9])\\1{1}");
Matcher match = regex.matcher(word);
if (match.find()) {
return true;
}
return false;
}
}