From 2c6e8912516541ca2a380c3bb35a656fe7afdab2 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 28 Jan 2019 10:53:32 +0000 Subject: [PATCH] JAL-3141 improvement on BackupFilenameParts filename matching --- src/jalview/io/BackupFilenameParts.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/jalview/io/BackupFilenameParts.java b/src/jalview/io/BackupFilenameParts.java index a4fbb3b..4f93ece 100644 --- a/src/jalview/io/BackupFilenameParts.java +++ b/src/jalview/io/BackupFilenameParts.java @@ -93,7 +93,11 @@ public class BackupFilenameParts if (filename.length() >= startLength + digits + endLength && filename.startsWith(base + templateStart) && filename.endsWith(templateEnd) - && numString.matches("[0-9]*")) + // match exactly digits number of number-characters (numString + // should be all digits and at least the right length), or more than + // digits long with proviso it's not zero-leading. + && (numString.matches("[0-9]{" + digits + "}") + || numString.matches("[1-9][0-9]{" + digits + ",}"))) { this.base = extensionMatch ? savedFilename + base : base; this.templateStart = templateStart; -- 1.7.10.2