Browse Source

Added new regex for floats and a test to test them

pull/8/head
Bill Burke 11 years ago
parent
commit
cad4440ea7
  1. 3
      jquery.parse.js
  2. 30
      tests.js

3
jquery.parse.js

@ -50,7 +50,8 @@ @@ -50,7 +50,8 @@
var _config = config;
var _errors = [];
var _regex = {
floats: /^-?\d+(\.\d+)?$/,
// floats: /^-?\d+(\.\d+)?$/,
floats : /^(\s*)(-?)[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/,
empty: /^\s*$/
}
var _state = emptyState();

30
tests.js

@ -366,6 +366,36 @@ var tests = [ @@ -366,6 +366,36 @@ var tests = [
}
}
]
},
{
input: "F1,F2,F3\n2,-2, 2\n 2. ,.2, .2 ",
cases: [
{
config: { delimiter: ",", header: true, dynamicTyping: true },
expected: {
"results": {
"fields": [
"F1",
"F2",
"F3"
],
"rows": [
{
"F1": 2,
"F2": -2,
"F3": 2
},
{
"F1": 2,
"F2": .2,
"F3": .2
}
]
},
"errors": []
}
}
]
}
];

Loading…
Cancel
Save