I\'m trying the username chains in Java with following rules:
Sarkiroka solution is right, but forgot the dash and the point should be escaped.
You should add as \ to escape it, but mind that in Java the backslash is itself used to escape, so if you are writing the regex in a java file, you should write
String regex = "[a-zA-Z0-9\\._\\-]{3,}";
Note the double back slashes.