From 2131aa385ea8572e2580d094f467bf1403891122 Mon Sep 17 00:00:00 2001 From: snowyplover Date: Sun, 17 Jan 2016 01:40:56 -0800 Subject: 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 --- src/regex.js | 4 ++-- 1 file 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 +} -- cgit v1.2.3