Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var str = "1+2.2*3.3";
- var numbers = str.match(/(\d+(?:\.\d+)?)/g);
- var signs = str.match(/[+\-*\/]/g);
- var priorities = {"+": 1, "-": 1, "*": 2, "/": 2};
- console.log(numbers);
- console.log(signs);
- var EvalTree = function() {
- this.left = null;
- this.right = null;
- this.value = null;
- this.add = function(operandL, operandR, sign) {
- this.
- }
- };
- var parseTree = new EvalTree();
- var num = 0;
- priorities.sort(function(a, b) {
- return b[1] - a[1];
- });
- for(var i in signs) {
- if(signs[i] in prorities) {
Advertisement
Add Comment
Please, Sign In to add comment