public static boolean isValidName(String text)
{
Pattern pattern = Pattern.compile(\"^[^/./\\\\:*?\\\"<>|]+$\");
Matcher matcher = pattern.matcher(text
Looks good. At least if we believe to this resource: http://msdn.microsoft.com/en-us/library/aa365247%28v=vs.85%29.aspx
But I'd simplify use the code. It is enough to look for one of these characters to say that the name is invalid, so:
public static boolean isValidName(String text)
{
Pattern pattern = Pattern.compile("[^/./\\:*?\"<>|]");
return !pattern.matcher(text).find();
}
This regex is simpler and will work faster.