summaryrefslogtreecommitdiff
path: root/lisp/ldg-regex.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-04-02 23:13:23 -0700
committerCraig Earls <enderw88@gmail.com>2013-04-02 23:13:23 -0700
commit519e57ca1fac01ea057bea8263c6cb06a8ac4e7e (patch)
tree83529f38b2fb22b4ac5e29c3cc4c4c6047be5309 /lisp/ldg-regex.el
parent86d0fd87c49e20b0f5262e7ae48234986584b750 (diff)
downloadfork-ledger-519e57ca1fac01ea057bea8263c6cb06a8ac4e7e.tar.gz
fork-ledger-519e57ca1fac01ea057bea8263c6cb06a8ac4e7e.tar.bz2
fork-ledger-519e57ca1fac01ea057bea8263c6cb06a8ac4e7e.zip
Consolidated all major regexes into ldg-regex. Only major exception are the regex in ledger context at point.
Diffstat (limited to 'lisp/ldg-regex.el')
-rw-r--r--lisp/ldg-regex.el35
1 files changed, 34 insertions, 1 deletions
diff --git a/lisp/ldg-regex.el b/lisp/ldg-regex.el
index 7c92bf15..24a3ae23 100644
--- a/lisp/ldg-regex.el
+++ b/lisp/ldg-regex.el
@@ -24,11 +24,23 @@
(eval-when-compile
(require 'cl))
+(defvar ledger-amount-decimal-comma-regex
+ "-?[1-9][0-9.]*[,]?[0-9]*")
+
+(defvar ledger-amount-decimal-period-regex
+ "-?[1-9][0-9.]*[.]?[0-9]*")
+
(defvar ledger-other-entries-regex
- "^\\(\\([~=].+\\)\\|\\(^\\([A-Za-z]+ .+\\)\\)\\)")
+ "\\(^[~=A-Za-z].+\\)+")
+;\\|^\\([A-Za-z] .+\\)\\)
+
+(defvar ledger-xact-payee-regex
+ (concat "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+"
+ "\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)"))
(defvar ledger-comment-regex
"\\( \\| \\|^\\)\\(;.*\\)")
+
(defvar ledger-payee-pending-regex
"^[0-9]+[-/.=][-/.=0-9]+\\s-\\!\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)")
@@ -38,19 +50,40 @@
(defvar ledger-payee-uncleared-regex
"^[0-9]+[-/.=][-/.=0-9]+\\s-+\\(([^)]+)\\s-+\\)?\\([^*].+?\\)\\(\\( ;\\| ;\\|$\\)\\)")
+(defvar ledger-iso-date-regex
+ "\\([12][0-9]\\{3\\}\\)[-/]\\([0-9]\\{2\\}\\)[-/]\\([0-9]\\{2\\}\\)")
+
+(defvar ledger-init-string-regex
+ "^--.+?\\($\\|[ ]\\)")
(defvar ledger-posting-account-all-regex
"\\(^[ \t]+\\)\\(.+?\\)\\( \\|$\\)")
+(defvar ledger-sort-next-record-regex
+ (concat "^[0-9/.=-]+\\(\\s-+\\*\\)?\\(\\s-+(.*?)\\)?\\s-+"
+ "\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)"))
+
(defvar ledger-posting-account-cleared-regex
"\\(^[ \t]+\\)\\(\\*.+?\\)\\( \\|$\\)")
+(defvar ledger-complete-account-regex
+ "^[ \t]+\\([*!]\\s-+\\)?[[(]?\\(.+?\\)\\(\t\\|\n\\| [ \t]\\)")
+
(defvar ledger-posting-account-pending-regex
"\\(^[ \t]+\\)\\(!.+?\\)\\( \\|$\\)")
(defvar ledger-date-regex
"\\([0-9]+\\)[/-]\\([0-9]+\\)[/-]\\([0-9]+\\)")
+(defvar ledger-post-amount-regex
+ (concat "\\( \\|\t\\| \t\\)[ \t]*-?"
+ "\\([A-Z$€£_]+ *\\)?"
+ "\\(-?[0-9,]+?\\)"
+ "\\(.[0-9]+\\)?"
+ "\\( *[[:word:]€£_\"]+\\)?"
+ "\\([ \t]*[@={]@?[^\n;]+?\\)?"
+ "\\([ \t]+;.+?\\|[ \t]*\\)?$"))
+
(defmacro ledger-define-regexp (name regex docs &rest args)
"Simplify the creation of a Ledger regex and helper functions."
(let ((defs