function newPat = maskedPattern(pat,mask)
%maskedPattern Creates a pattern with a custom display
%   NEWPAT = maskedPattern(PAT) returns a pattern that uses the name of
%   workspace variable PAT when displaying NEWPAT.
%
%   NEWPAT = maskedPattern(PAT,MASK) returns a pattern that prints MASK instead 
%   of the default display for PAT when displaying NEWPAT.
%
%   Examples
%       hexDigit = characterListPattern('0','9') | characterListPattern('a','f');
%       hexNum = "0x" + asManyOfPattern(hexDigit,1)
%       % hexNum = 
%       %   pattern
%       %   Matching:
%       %     "0x" + asManyOfPattern(characterListPattern("0","9") | characterListPattern("a","f"),1)
%       %   Show all details
% 
%       hexDigit = maskedPattern(hexDigit);
%       hexNum = "0x" + asManyOfPattern(hexDigit,1)
%       % hexNum = 
%       %   pattern
%       %   Matching:
%       %     "0x" + asManyOfPattern(hexDigit,1)
%       %   Show all details
%
%   See also pattern, contains, extract, replace, regexp, regexprep, inputname.

% Copyright 2019-2020 The MathWorks, Inc.

    narginchk(1,2);

    try
        if nargin == 1
            mask = inputname(1);
            if isempty(mask)
                error(message('MATLAB:pattern:MissingMask'));
            end
        end
            
        newPat = matlab.internal.pattern.maskedPattern(pat,mask);
	
    catch e
        throw(e);
    end
end