wrote:
> Hi!
>
> I have a javaprogram that should read xml-files from a directory. The
> program could contain several types of files but it should only read
> files with a certain pattern.
>
> The file names will look like this:
>
> "resultset_27_23.xml"
>
> where the numbers will change, but the rest of the file name is the
> same (resultset_XX_XX.xml).
>
> But in the same directory it will also be files with the following
> pattern:
>
> "resultset_27_23_attachment1.xml"
>
> Here, the numbers could change in the in the same way as the files
> above, and the number after the text (attachment) could also differ
> from file to file.Those files should not be read by the program.
>
> I have tried to write a regular expression pattern that only reads the
> first file types, and exlcudes the other ones, but it won´t work.
>
> Does anyone have a solution to my problem? It is possible to use either
> just one pattern, or two patterns; one for the files that should be
> included, and one for the files that should be excluded.
>
I haven't tried it, but this may work:
"resultset_\\d\\d_\\d\\d\\.xml";
\d represents a single digit. \. escapes the dot. All backslashes are
doubled up so they are treated as literals in a Java string.