function [var_order,pos] = Find_Var(expr,var)

pos = [];
var_order = [];

L_expr = length(expr);
L_var = length(var);

for i = 1:L_expr
    j=1;
    while(j<=L_var)
        L = length(var{j})-1;
        if(i==1 & i+L<L_expr)
            if(strcmp(expr(i:i+L),var{j}) & ~isletter(expr(i+L+1)))
                pos = [pos,[i;i+L]];
                var_order = [var_order,{var{j}}];
                j = L_expr;
                i = i+L+1;
            end
        elseif(i>1 & i+L<L_expr)
            if(strcmp(expr(i:i+L),var{j}) & ~isletter(expr(i-1)) & ~isletter(expr(i+L+1)))
                pos = [pos,[i;i+L]];
                var_order = [var_order,{var{j}}];
                j = L_expr;     
                i = i+L+1;
            end            
        elseif(i> 1 & i+L==L_expr)
            if(strcmp(expr(i:i+L),var{j}) & ~isletter(expr(i-1)))
                pos = [pos,[i;i+L]];
                var_order = [var_order,{var{j}}];
                j = L_expr;     
                i = i+L+1;
            end         
        elseif(i==1 & i+L==L_expr)
            if(strcmp(expr(i:i+L),var{j}))
                pos = [pos,[i;i+L]];
                var_order = [var_order,{var{j}}];
                j = L_expr;
                i = i+L+1;
            end  
        end
        j = j+1;
    end
end
