Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for spaces in numbers

  • Loading branch information...
commit 60c0eb9e05b691a68d6efd352a31494b9c951305 1 parent 2d4c1df
@netzhuffle authored
Showing with 5 additions and 1 deletion.
  1. +1 −1  src/Expression.js
  2. +4 −0 test/index.html
View
2  src/Expression.js
@@ -142,5 +142,5 @@ var Expression = new Class({
});
Expression.extend({
- pattern: " *([0-9A-Za-z]+ *([-+*] *[0-9A-Za-z]+ *)*[-+*]? *)?"
+ pattern: " *([0-9A-Za-z][ 0-9A-Za-z]* *([-+*] *[0-9A-Za-z][ 0-9A-Za-z]* *)*[-+*]? *)?"
});
View
4 test/index.html
@@ -123,6 +123,9 @@ <h2 id="qunit-userAgent"></h2>
e = new Expression("1");
ok(e.isValid(), "1");
+ e = new Expression("1 2 3");
+ ok(e.isValid(), "spaces in numbers");
+
e = new Expression("2+5-3-az*abcdefghijklmnopqrstuvwxyz-0z1ABCDEFGHIJKLMNOPQRSTUVWXYZ*1");
ok(e.isValid(), "long case changing string");
@@ -160,6 +163,7 @@ <h2 id="qunit-userAgent"></h2>
ok(RegExp("^" + Expression.pattern + "$"), "pattern valid RegExp");
ok(RegExp("^" + Expression.pattern + "$").test("ABCDE0FGHIJ1KLMNO2PQRS3TU4VW5XY6Z+0zab7cdefg8hijklmnop9qrstuvwxyz*0987654321*1+0+"), "working pattern");
ok(RegExp("^" + Expression.pattern + "$").test(""), "working pattern for empty string");
+ ok(RegExp("^" + Expression.pattern + "$").test("1 2 3"), "spaces in numbers");
ok(!RegExp("^" + Expression.pattern + "$").test("ab#23"), "invalid chars");
ok(!RegExp("^" + Expression.pattern + "$").test("a++2"), "plus plus");
ok(!RegExp("^" + Expression.pattern + "$").test("a+-2"), "plus minus");
Please sign in to comment.
Something went wrong with that request. Please try again.