functionsplit_on
type(string_t) function split_on(text, sep) result(parts)
The parts of text between the characters sep, including empty ones.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| text | 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 split_on(text, sep) result(parts)
character(len=*), intent(in) :: text !! the text
character, intent(in) :: sep !! the separator
type(string_t), allocatable :: parts(:)
integer :: i, j
allocate (parts(0))
i = 1
do
j = index(text(i:), sep)
if (j == 0) then
call push(parts, text(i:))
exit
end if
call push(parts, text(i:i + j - 2))
i = i + j
end do
end function split_on