summaryrefslogtreecommitdiff
path: root/lisp/ledger-regex.el
diff options
context:
space:
mode:
authorMatus Goljer <matus.goljer@gmail.com>2015-09-28 18:03:32 +0200
committerMatus Goljer <matus.goljer@gmail.com>2015-09-28 18:03:32 +0200
commit767ab3e39c8dd6024c0904370654e5f0a9e24b2d (patch)
treedd64c6837cb54ebef6b6de412097eb7646733aa6 /lisp/ledger-regex.el
parent4dec0e3829e0d5b9da798265cc60a3feedd57f88 (diff)
downloadfork-ledger-767ab3e39c8dd6024c0904370654e5f0a9e24b2d.tar.gz
fork-ledger-767ab3e39c8dd6024c0904370654e5f0a9e24b2d.tar.bz2
fork-ledger-767ab3e39c8dd6024c0904370654e5f0a9e24b2d.zip
Align amounts on the decimal separator.
That is: A $10.00 B $5 C -$15.00 Before the numbers aligned at the end of the last digit.
Diffstat (limited to 'lisp/ledger-regex.el')
-rw-r--r--lisp/ledger-regex.el10
1 files changed, 8 insertions, 2 deletions
diff --git a/lisp/ledger-regex.el b/lisp/ledger-regex.el
index cf86b2f9..6ced0223 100644
--- a/lisp/ledger-regex.el
+++ b/lisp/ledger-regex.el
@@ -27,8 +27,14 @@
(defconst ledger-amount-regex
(concat "\\( \\|\t\\| \t\\)[ \t]*-?"
"\\([A-Z$€£₹_(]+ *\\)?"
- "\\(-?[0-9,]+\\)"
- "\\(\\.[0-9)]+\\)?"
+ ;; We either match just a number after the commodity with no
+ ;; decimal or thousand separators or a number with thousand
+ ;; separators. If we have a decimal part starting with `,'
+ ;; or `.', because the match is non-greedy, it must leave at
+ ;; least one of those symbols for the following capture
+ ;; group, which then finishes the decimal part.
+ "\\(-?\\(?:[0-9]+\\|[0-9,.]+?\\)\\)"
+ "\\([,.][0-9)]+\\)?"
"\\( *[[:word:]€£₹_\"]+\\)?"
"\\([ \t]*[@={]@?[^\n;]+?\\)?"
"\\([ \t]+;.+?\\|[ \t]*\\)?$"))