function s2 = s_trim ( s )

%*****************************************************************************80
%
%% s_trim() returns a character string to the last nonblank.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 August 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    string S: the string.
%
%  Output:
%
%    string s2: a copy of the string to the last nonblank.
%
  len = length ( s );

  while ( 0 < len )
    if ( s(len) ~= ' ' )
      break;
    end
    len = len - 1;
  end

  s2 = s(1:len);

  return
end
