/\d+/ matches any string that has 1 or more digits anywhere in it. If you want a string with only digits, you need to anchor the regex:
/^\d+$/. Or in your case, match digits followed by a period and "txt":
/^\d+\.txt$/
That says "match the start of the string, followed by 1 or more digits, then a period, then txt, then the end of the string.