How to add methods to a function

Suppose it has the task of writing a function that splits a given string at the points where there is a character change from one from to another to set.
To delimit the context, suppose that the from and the to can be defined as Set or as Array or as functions, even in mixed combination if necessary.

Below is an idea of one of the methods that handles the combination from :: Function and to :: Function.

What is (or one of) Julian’s “correct” way (syntax, strategy) to set up this function and its methods?

function splitonswitch(str, from, to)
l=1
spl=String[]
d=length(str)
for i in eachindex(str)
    if from(str[i])&&to(str[min(i+1,d)])
        push!(spl, str[l:i])
        l=i+1
    end
    
end
push!(spl,str[l:end])
end

is the following way okay?

splitonswitch(str, From::Set, To::Set)= splitsonwitch(str, c->c ∈ From,c->c ∈ To)

since the method that uses functions as parameters from and to expects functions that have a boolean as output, do I have to, in any way, impose it in the definition of the parameters?
or should i do the checking inside the code?
and how?

You have a typo in the function name for the second method.

Thanks! I fix it.