summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowyplover <the.estuary@gmail.com>2016-01-17 01:40:56 -0800
committersnowyplover <the.estuary@gmail.com>2016-01-17 01:40:56 -0800
commit2131aa385ea8572e2580d094f467bf1403891122 (patch)
tree55b4dd11fa488ab44287621cfab2f3e4cc953578
parentbda9f32dcd38ff1e71b5783bfa26f3012ae3cc7c (diff)
downloadsvg.js-2131aa385ea8572e2580d094f467bf1403891122.tar.gz
svg.js-2131aa385ea8572e2580d094f467bf1403891122.zip
Fix regex for isNumber
Description of necessary functionality for a regex that matches Javascript numbers found in Eloquent Javascript, (Ch 9, last exercise). See: http://eloquentjavascript.net/09_regexp.html#h_izldJoT3uv
-rw-r--r--src/regex.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/regex.js b/src/regex.js
index 1b26afd..d2e6c78 100644
--- a/src/regex.js
+++ b/src/regex.js
@@ -34,7 +34,7 @@ SVG.regex = {
, isBlank: /^(\s+)?$/
// Test for numeric string
-, isNumber: /^-?[\d\.]+$/
+, isNumber: /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i
// Test for percent value
, isPercent: /^-?[\d\.]+%$/
@@ -64,4 +64,4 @@ SVG.regex = {
// matches X
, X: /X/g
-} \ No newline at end of file
+}