implemented dispatcher commands

This commit is contained in:
Borys Levytskyi
2015-04-03 18:55:39 +03:00
parent d301d0c317
commit 8e5be22fe3
6 changed files with 136 additions and 54 deletions

View File

@@ -1,8 +1,11 @@
(function() {
var twoOperandsRegex = /^(\d+)(<<|>>|\||\&|\^)(\d+)$/;
var twoOperandsRegex = /^(\d+)\s*(<<|>>|\||\&|\^)\s*(\d+)$/;
var numbersList = /^((\d*)+\s?)+$/;
app.service('expression', {
canParse: function(string) {
return twoOperandsRegex.test(string) || numbersList.test(string);
},
parse: function(string) {
var trimmed = string.replace(/^\s+|\s+$/, '');
var matches = twoOperandsRegex.exec(trimmed);