]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Update regex date match patterns
authorfantasticle <84633558+fantasticle@users.noreply.github.com>
Wed, 30 Mar 2022 10:19:30 +0000 (12:19 +0200)
committerGitHub <noreply@github.com>
Wed, 30 Mar 2022 10:19:30 +0000 (12:19 +0200)
src/documents/parsers.py

index cb70f4fc6b1d41ee98c7828cecf96d70dd9ee9a4..ca24026fb3159f0f23766bb2b3e5f6bb000623a6 100644 (file)
@@ -23,6 +23,7 @@ from documents.signals import document_consumer_declaration
 # - XX. MONTH ZZZZ with XX being 1 or 2 and ZZZZ being 2 or 4 digits
 # - MONTH ZZZZ, with ZZZZ being 4 digits
 # - MONTH XX, ZZZZ with XX being 1 or 2 and ZZZZ being 4 digits
+# - XX MON ZZZZ with XX being 1 or 2 and ZZZZ being 4 digits, MONTH is 3 letters, e.g. 22-FEB-2022
 
 # TODO: isnt there a date parsing library for this?
 
@@ -31,7 +32,8 @@ DATE_REGEX = re.compile(
     r"(\b|(?!=([_-])))([0-9]{4}|[0-9]{2})[\.\/-]([0-9]{1,2})[\.\/-]([0-9]{1,2})(\b|(?=([_-])))|"  # noqa: E501
     r"(\b|(?!=([_-])))([0-9]{1,2}[\. ]+[^ ]{3,9} ([0-9]{4}|[0-9]{2}))(\b|(?=([_-])))|"  # noqa: E501
     r"(\b|(?!=([_-])))([^\W\d_]{3,9} [0-9]{1,2}, ([0-9]{4}))(\b|(?=([_-])))|"
-    r"(\b|(?!=([_-])))([^\W\d_]{3,9} [0-9]{4})(\b|(?=([_-])))",
+    r"(\b|(?!=([_-])))([^\W\d_]{3,9} [0-9]{4})(\b|(?=([_-])))|"
+    r"(\b|(?!=([_-])))([0-9]{1,2}[ \.\/-][A-Z]{3}[ \.\/-][0-9]{4})(\b|(?=([_-])))|"
 )