Is this pattern correct?
logPattern = ^NAME.log(-\d+)?$ What is the purpose of this?
Quoting directly from regex101 - a great page for testing and explaining regular expressions:
/^NAME.log(-\d+)?$/ ^ assert position at start of the stringNAME matches the characters NAME literally (case sensitive). matches any character (except newline)log matches the characters log literally (case sensitive)Capturing group (-\d+)?
? Between zero and one time, as many times as possible, giving back as needed [greedy]- matches the character - literally\d match a digit [0-9]+ Between one and unlimited times, as many times as possible, giving back as needed [greedy]$ assert position at end of the stringSo basically, this searches for strings (particularly file names I suppose) matching the pattern NAME.log or NAME.log-123456789 (no limit on number of digits).
Most probably it should be changed to match literal dot instead of "any character", so a backslash (\) should be added before the dot in the expression.