function [outputText] = strrepbatch(text, oldnewstr, uniqueText)
%strrepbatch replaces many strings in a cell array of strings with many new
% strings. The goal of this is to save having to do this one at a time.
% Note: if string A is replaced with string B, and string B is replaced
% with string C in a subsequent line of oldnewstr, then A will be replaced
% with C, but not if the order of these replaces is reversed. Also, if the
% original list of strings is unique, we don't bother looking for unique
% values to save time.

textDim = size(text);
if uniqueText == 0
    [uniqueText, ~, index] = unique(text);

    for n=1:size(oldnewstr,1)
        uniqueText=strrep(uniqueText,oldnewstr{n,1},oldnewstr{n,2});
    end
    outputText = uniqueText(index);
    outputText = reshape(outputText,textDim(1),[]);
elseif uniqueText == 1
    for n=1:size(oldnewstr,1)
        text=strrep(text,oldnewstr{n,1},oldnewstr{n,2});
    end

    outputText = text;
end