What you need is Unicode!
Unicode code properites
Pattern p = Pattern.compile("^(?=.*\p{Nd})(?=.*\p{L})[\p{L}\p{Nd}]{2,10}$");
\p{L}
and \p{Nd}
are Unicode properties, where
\p{L}
is any kind of letter from any language
\p{Nd}
is a digit zero through nine in any script except ideographic scripts
For more details on Unicode properties see regular-expressions.info
Pattern.UNICODE_CHARACTER_CLASS
There is also a new property Pattern.UNICODE_CHARACTER_CLASS
that enables the Unicode version of the predefined character classes see my answer here for some more details and links
You could do something like this
Pattern p = Pattern.compile("^(?=.*\\d)(?=.*[A-Za-z])\\w{2,10}$", Pattern.UNICODE_CHARACTER_CLASS);
and \w
would match all letters and all digits from any languages (and of course some word combining characters like _
).
Error in your regex
I also changed your regex a bit. Your original lookaheads ((?=.\d)(?=.[A-Za-z])
) would check for the second character being a letter and a digit, what is failing in all ways, my version with the quantifier checks for if they are anywhere in the string.