From b53b05496d2a03999fe1f8b2276b935aa815aa6f Mon Sep 17 00:00:00 2001 From: Geert Weening Date: Wed, 21 May 2014 09:39:40 -0700 Subject: [PATCH 1/3] [CHORE] remove non-capturing group (?:) it doesn't affect the matching, seems superfluous --- src/js/ripple/amount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/ripple/amount.js b/src/js/ripple/amount.js index 9775c3d6..50bcea72 100644 --- a/src/js/ripple/amount.js +++ b/src/js/ripple/amount.js @@ -594,7 +594,7 @@ Amount.prototype.invert = function() { * USD 100.40 => 100.4/USD/? * 100 => 100000000/XRP */ -Amount.human_RE = /^\s*([a-z]{3})?\s*(-)?(\d+)(?:\.(\d*))?\s*([a-f0-9]{40}|[a-z0-9]{3})?\s*$/i; +Amount.human_RE = /^\s*([a-z]{3})?\s*(-)?(\d+)(\.(\d*))?\s*([a-f0-9]{40}|[a-z0-9]{3})?\s*$/i; Amount.prototype.parse_human = function(j, opts) { opts = opts || {}; From 8be08b5e735aa05cb14ce9f079de951f448f4286 Mon Sep 17 00:00:00 2001 From: Geert Weening Date: Wed, 21 May 2014 09:40:40 -0700 Subject: [PATCH 2/3] [DOC] regex breakdown for human parseble amount --- src/js/ripple/amount.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/js/ripple/amount.js b/src/js/ripple/amount.js index 50bcea72..93cec17b 100644 --- a/src/js/ripple/amount.js +++ b/src/js/ripple/amount.js @@ -593,6 +593,21 @@ Amount.prototype.invert = function() { * 25.2 XRP => 25200000/XRP * USD 100.40 => 100.4/USD/? * 100 => 100000000/XRP + * + * + * The regular expression below matches above cases, broken down for better understanding: + * + * ^\s* // start with any amount of whitespace + * ([a-z]{3})? // optional any 3 letters + * \s* // any amount of whitespace + * (-)? // optional dash + * (\d+) // 1 or more digits + * (\.(\d*))? // optional . character with any amount of digits + * \s* // any amount of whitespace + * ([a-f0-9]{40}|[a-z0-9]{3})? // optional 40 character hex string OR 3 letters + * \s* // any amount of whitespace + * $ // end of string + * */ Amount.human_RE = /^\s*([a-z]{3})?\s*(-)?(\d+)(\.(\d*))?\s*([a-f0-9]{40}|[a-z0-9]{3})?\s*$/i; From 77a323aaae013dc35c2d9b68db383adb0cbc42c5 Mon Sep 17 00:00:00 2001 From: Geert Weening Date: Wed, 21 May 2014 09:40:50 -0700 Subject: [PATCH 3/3] [CHJORE] gitignore intellij files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 33d99e09..870069a7 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ test/config.js /src-cov /coverage.html /coverage + +# Ignore IntelliJ files +.idea \ No newline at end of file