In general, a regular expression for a file name that contains the words "registry of transactions" and the specific date will be as follows:
^.*ัะตะตััั\s+ัะดะตะปะพะบ.*{ะดะฐัะฐ}.*$
^ - beginning of line.* - any number of any characters\s+ - one or more spaces{ะดะฐัะฐ} - the date to be found (in plain text, escaping dots \. , because a dot in a regular expression means any character )$ - end of line
It is better to first prepare a regular expression pattern, and then use it. For example, in your case, you can prepare it as follows:
Date date = new Date(); SimpleDateFormat format = new SimpleDateFormat("dd\\.MM\\.yyyy"); Pattern pattern = Pattern.compile( String.format("^.*ัะตะตััั\\s+ัะดะตะปะพะบ.*%s.*$", format.format(date)), Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE );
date - in this case, the current date, but you can use any other- Date formatting with the
dd\\.MM\\.yyyy template for screening points - use of
CASE_INSENSITIVE flags CASE_INSENSITIVE that the case of letters and UNICODE_CASE not taken into account, so that the case of letters for the Russian alphabet is correctly processed
Then you can use this template in the filtering function:
List<String> list = Arrays.stream(files) .filter(f -> pattern.matcher(f).matches()) .collect(Collectors.toList());