functiontop_split
type(string_t) function top_split(s, sep) result(parts)
The parts of s between the characters sep outside brackets and strings, each stripped.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| s | character(len=*) | in | the text | |
| sep | character(len=1) | in | the separator |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| parts | type(string_t) | privateallocatabledimension(:) |
Calls
Source
Show the code
function top_split(s, sep) result(parts)
character(len=*), intent(in) :: s !! the text
character, intent(in) :: sep !! the separator
type(string_t), allocatable :: parts(:)
integer :: start, at
allocate (parts(0))
start = 1
do
at = top_index(s(start:), sep)
if (at == 0) exit
call push(parts, strip(s(start:start + at - 2)))
start = start + at
end do
call push(parts, strip(s(start:)))
end function top_split