=====утверждения lookahead=====
Регулярное выражение:
^(?=(?:\D*\d){0,3}\D*$).{6,25}$
Объяснение:
^ # Start of string
(?= # Assert that the following can be matched here:
(?:\D*\d) # Any number of non-digits, followed by one digit
{0,3} # (zero to three times)
\D* # followed by only non-digits
$ # until the end of the string
) # (End of lookahead)
.{6,25} # Match 6 to 25 characters (any characters except newlines)
$ # End of string
[[http://www.regular-expressions.info/lookaround.html|подробнее]]