JAL-3141 improvement on BackupFilenameParts filename matching
authorBen Soares <bsoares@dundee.ac.uk>
Mon, 28 Jan 2019 10:53:32 +0000 (10:53 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Mon, 28 Jan 2019 10:53:32 +0000 (10:53 +0000)
src/jalview/io/BackupFilenameParts.java

index a4fbb3b..4f93ece 100644 (file)
@@ -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;