function s = extractAfter(str, pos)
% EXTRACTAFTER Extract substring after specified position
%    S = EXTRACTAFTER(STR, PAT) returns a substring of STR that
%    starts with the character after the first occurrence of PAT and
%    ends with the last character of STR.
%
%    S = EXTRACTAFTER(STR, POS) returns a substring of STR that starts
%    with the character after numeric position POS and ends with the last
%    character of STR. POS must be an integer between 0 and the number of
%    characters in STR.
%
%    NOTE: STR must be text, which means it can be a string array, a character 
%    vector, or a cell array of character vectors. PAT must be text or a 
%    pattern array. The output S has the same data type as STR.
%
%    Examples:
%        STR = "The quick brown fox";
%        PAT = 'quick ';
%        extractAfter(STR,PAT)
%
%        % returns "brown fox"
%
%        STR = "The answer is either 24 or 42";
%        PAT = digitsPattern;
%        extractAfter(STR,PAT)
%
%        % returns " or 42"
%
%        STR = 'peppers and onions';
%        POS = 12;
%        extractAfter(STR,POS)
%
%        % returns 'onions'
%
%    See also EXTRACTBEFORE, EXTRACTBETWEEN, PATTERN, DIGITSPATTERN

%   Copyright 2016-2020 The MathWorks, Inc.

    narginchk(2, 2);
    if ~isTextStrict(str)
        firstInput = getString(message('MATLAB:string:FirstInput'));
        error(message('MATLAB:string:MustBeCharCellArrayOrString', firstInput));
    end

    try
        s = string(str);
        s = s.extractAfter(pos);
        s = convertStringToOriginalTextType(s, str);
        
    catch E
        throw(E);
    end
end
