Thanks for your response. I am having trouble getting a true result
from the Pattern matches statement.
As a quick test I did this:
private void pathForName(String name) {
if ((name == null) || (name.length() == 0)) {
return;
}
boolean b1 = Pattern.matches("^" + LEGAL_CHARACTERS, name);
System.out.print(String.format(
"Pattern: %s\n Name: %s\n Evaluates as: %s\n",
"^" + LEGAL_CHARACTERS,
name,
Boolean.toString(b1))
);
}
public void testPathForName() {
pathForName("foo"); // expect false
pathForName("FOO"); // expect true?
pathForName("<,."); // expect true
}
The result was this:
Pattern: ^abcdefghijklmnopqrstuvwxyz0123456789_$()+-/
Name: foo
Evaluates as: false
Pattern: ^abcdefghijklmnopqrstuvwxyz0123456789_$()+-/
Name: FOO
Evaluates as: false
Pattern: ^abcdefghijklmnopqrstuvwxyz0123456789_$()+-/
Name: <,.
Evaluates as: false
I expected strings two and three to be invalid, but they all were
evaluated as valid.
Please let me know where I may have erred.
Also, I am curious about the String.replace line where "/" is replaced
with ":". Is this just to generate a valid file name?
Thank you.
--
Regards,
Brian