function f_out = BR_sub_values_v2(f,a_probs,not_index,indexes,var_index)
%

f_out = [];
len_f = length(f);

if ~isempty(indexes)
    num_indexes = length(indexes);
    e = 0;
    while e<len_f
        e = e + 1;
        if f(e)=='x'
            e1 = e + 2;
            digits = [];
            while f(e1)~=')'
                digits = [digits,f(e1)];
                e1 = e1 + 1;
            end
            index = str2num(digits);
            n = num2str(a_probs(var_index(index)));
            if index==not_index
                f_out = [f_out,'x'];
                e = e1;
            else
                f_out = [f_out,n];
                e = e1;
            end
        else
            f_out = [f_out,f(e)];
        end
    end
else
    return
end
tch = 0;
