fdoc

functionsplit_on

type(string_t) function split_on(text, sep) result(parts)

The parts of text between the characters sep, including empty ones.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the text

sepcharacter(len=1)in

the separator

Result

NameTypeAttributesDescription
partstype(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

Graphs

Calls

Called by