From 9837b1ed8b49ccec4c5c810f635e4ce4e36c9533 Mon Sep 17 00:00:00 2001 From: ch010060 Date: Wed, 1 Feb 2023 22:41:04 +0800 Subject: [PATCH] Improve work code regex precision. --- dlsite_renamer-cli.py | 2 +- dlsite_renamer.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlsite_renamer-cli.py b/dlsite_renamer-cli.py index ee532af..3a9c231 100644 --- a/dlsite_renamer-cli.py +++ b/dlsite_renamer-cli.py @@ -31,7 +31,7 @@ # re.compile()返回一個匹配對像 # ensure path name is exactly RJ?(\d{8}d{7}d{6}) or BJ?(\d{8}d{7}d{6}) or VJ?(\d{8}d{7}d{6}) -pattern = re.compile("([BRV][EJ])?(\d{8}|\d{7}|\d{6})") +pattern = re.compile("([BRV][EJ])?(\d{8}|\d{7}|\d{6})|$") # filter to substitute illegal filenanme characters to " " filter = re.compile('[\\\/:"*?<>|]+') diff --git a/dlsite_renamer.py b/dlsite_renamer.py index 7302105..81e211c 100644 --- a/dlsite_renamer.py +++ b/dlsite_renamer.py @@ -29,7 +29,7 @@ # re.compile()返回一個匹配對像 # ensure path name is exactly RJ?(\d{8}d{7}d{6}) or BJ?(\d{8}d{7}d{6}) or VJ?(\d{8}d{7}d{6}) -pattern = re.compile("([BRV][EJ])?(\d{8}|\d{7}|\d{6})") +pattern = re.compile("([BRV][EJ])?(\d{8}|\d{7}|\d{6})|$") # filter to substitute illegal filenanme characters to " " filter = re.compile('[\\\/:"*?<>|]+')