private static boolean isOk ( String txt ) { if ( UPPER_THEN_LOWER . matcher ( txt ) . matches ( ) ) return true ; int ints = 0 ; for ( char c : txt . toCharArray ( ) ) { if ( isDigit ( c ) ) { ints ++ ; } } if ( ints * 2 > txt . length ( ) ) return true ; return false ; }
Whitelisting . Ok if Uppercase - then - lowercases or 2x - more - digits - than - letters .