summaryrefslogtreecommitdiff
path: root/lisp/ldg-regex.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-04-16 08:58:12 -0700
committerCraig Earls <enderw88@gmail.com>2013-04-16 08:58:12 -0700
commit524ec0b6149d83a124860a51f2c37deff12f289d (patch)
treede442d39d2269a0b2a77deed185925c8b2aaf0fd /lisp/ldg-regex.el
parent909f9c4697a0c6bb1927d242d671597c0b96013c (diff)
parent03b3ef5f0b56286f7ee8498588f5d07c19d8b6f6 (diff)
downloadfork-ledger-524ec0b6149d83a124860a51f2c37deff12f289d.tar.gz
fork-ledger-524ec0b6149d83a124860a51f2c37deff12f289d.tar.bz2
fork-ledger-524ec0b6149d83a124860a51f2c37deff12f289d.zip
Merge pull request #176 from georgek/regex
OK, lets try again. Thanks for working on this!
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."