summaryrefslogtreecommitdiff
path: root/lisp/ldg-regex.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ldg-regex.el')
-rw-r--r--lisp/ldg-regex.el14
1 files changed, 9 insertions, 5 deletions
diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el
index 736fd811..c9e60e71 100644
--- a/lisp/ldg-regex.el
+++ b/lisp/ldg-regex.el
@@ -46,16 +46,16 @@
"^[;#|\\*%].*\\|[ \t]+;.*")
(defconst ledger-payee-any-status-regex
- "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)")
+ "^[0-9]+[-/][-/.=0-9]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+\\(.+?\\)\\s-*\\(;\\|$\\)")
(defconst ledger-payee-pending-regex
- "^[0-9]+[-/][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(;\\|$\\)")
+ "^[0-9]+[-/][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)")
(defconst ledger-payee-cleared-regex
- "^[0-9]+[-/][-/.=0-9]+\\s-\\*\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(;\\|$\\)")
+ "^[0-9]+[-/][-/.=0-9]+\\s-\\*\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)")
(defconst ledger-payee-uncleared-regex
- "^[0-9]+[-/][-/.=0-9]+\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(;\\|$\\)")
+ "^[0-9]+[-/][-/.=0-9]+\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\s-*\\(;\\|$\\)")
(defconst ledger-init-string-regex
"^--.+?\\($\\|[ ]\\)")
@@ -78,7 +78,11 @@
"\\|"
ledger-metadata-regex))
-
+(defmacro rx-static-or (&rest rx-strs)
+ "Returns rx union of regexps which can be symbols that eval to strings."
+ `(rx (or ,@(mapcar #'(lambda (rx-str)
+ `(regexp ,(eval rx-str)))
+ rx-strs))))
(defmacro ledger-define-regexp (name regex docs &rest args)
"Simplify the creation of a Ledger regex and helper functions."