Skip to content

Instantly share code, notes, and snippets.

@brownsoo
Created February 3, 2017 02:27
Show Gist options
  • Save brownsoo/adc474fb45fbbc5ee774a87571072f8c to your computer and use it in GitHub Desktop.
Save brownsoo/adc474fb45fbbc5ee774a87571072f8c to your computer and use it in GitHub Desktop.
Regular expression to check if the same char is repeated.
// 문자열에 반복되는 문자가 있는지 확인
public static boolean checkSameCharRepeated(@NonNull String password, int repeatLength) {
if (repeatLength <= 1) return false;
Pattern p = Pattern.compile(".*([a-zA-Z0-9])\\1{"+ (repeatLength - 1) +",}.*");
return p.matcher(password).matches();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment