elemental function strip(self, remove_nulls)
!< Return a copy of the string with the leading and trailing characters removed.
!<
!< @note Multiple subsequent separators are collapsed to one occurence.
!<
!<```fortran
!< type(string) :: astring
!< logical :: test_passed(1)
!< astring = ' Hello World! '
!< test_passed(1) = astring%strip()//''=='Hello World!'
!< print '(L1)', all(test_passed)
!<```
!=> T <<<
class(string), intent(in) :: self !< The string.
logical, intent(in), optional :: remove_nulls !< Remove null characters at the end.
type(string) :: strip !< The stripped string.
integer :: c !< Counter.
if (allocated(self%raw)) then
strip = self%adjustl()
strip = strip%trim()
if (present(remove_nulls)) then
if (remove_nulls) then
c = index(self%raw, char(0))
if (c>0) strip%raw = strip%raw(1:c-1)
endif
endif
endif
endfunction strip