From 8019a27a45e88ed6ea3fa101e05dca962ac0b624 Mon Sep 17 00:00:00 2001 From: Hans5958 Date: Fri, 29 Apr 2022 17:12:40 +0700 Subject: [PATCH] Fix commatization regex --- tools/formatter.py | 2 +- tools/migrate_atlas_format.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/formatter.py b/tools/formatter.py index 3f65e6fd..8c2833e1 100644 --- a/tools/formatter.py +++ b/tools/formatter.py @@ -21,7 +21,7 @@ - [place.reddit.com](https://place.reddit.com) """ FS_REGEX = { - "commatization": r'( *(,+ +|,+ |,+)| +)(and|&|;)( *(,+ +|,+ |,+)| +)|, *$| +', + "commatization": r'[,;& ]+(?:and)?[,;& ]*?', "pattern1": r'\/*[rR]\/([A-Za-z0-9][A-Za-z0-9_]{2,20})(?:\/$)?', "pattern2": r'^\/*[rR](?!\/)([A-Za-z0-9][A-Za-z0-9_]{2,20})(?:\/$)?', "pattern3": r'(?:(?:https?:\/\/)?(?:(?:www|old|new|np)\.)?)?reddit\.com\/r\/([A-Za-z0-9][A-Za-z0-9_]{2,20})(?:\/[^" ]*)*', diff --git a/tools/migrate_atlas_format.py b/tools/migrate_atlas_format.py index ffeaae7a..1aa088d1 100644 --- a/tools/migrate_atlas_format.py +++ b/tools/migrate_atlas_format.py @@ -15,7 +15,7 @@ EXPANSION_1_RANGE = (56, END_IMAGE) EXPANSION_2_RANGE = (109, END_IMAGE) -COMMATIZATION = re.compile(r'(?: *(?:,+ +|,+ |,+)| +)(?:and|&|;)(?: *(?:,+ +|,+ |,+)| +)|, *$| +') +COMMATIZATION = re.compile(r'[,;& ]+(?:and)?[,;& ]*?') FS_REGEX = re.compile(r'(?:(?:(?:(?:https?:\/\/)?(?:(?:www|old|new|np)\.)?)?reddit\.com)?\/)?[rR]\/([A-Za-z0-9][A-Za-z0-9_]{2,20})(?:\/[^" ]*)*') def migrate_atlas_format(entry: dict):