Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(string), | intent(in) | :: | self | The string. |
||
logical, | intent(in), | optional | :: | remove_nulls | Remove null characters at the end. |
The stripped string.
Return a copy of the string with the leading and trailing characters removed.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | c | Counter. |
elemental function strip(self, remove_nulls)
!---------------------------------------------------------------------------------------------------------------------------------
!< Return a copy of the string with the leading and trailing characters removed.
!---------------------------------------------------------------------------------------------------------------------------------
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
return
!---------------------------------------------------------------------------------------------------------------------------------
endfunction strip