I need to write a regular expression that will match
filenames that have a txt, htm, or html extension. I know that parens group
characters together and that brackets allow one character from a set to be
matched, so I tried combining these approaches, but it is not working. The
string to be tested is in parts[1]. The .* should match any number of
characters, and then \\. would be the dot, and then my attempt at combining
brackets and parentheses follows.
if (!Pattern.matches(".*\\.[(txt)(htm)(html)]",
parts[1])) {
System.err.println("501
Not Implemented: " + parts[1] + "\n");
}
Anonymous User
04-Feb-2015It should be: Example