The LHS ++ RHS template extends at compiletime to [ lhs0, lhs1, lhs2 | RHS] [ lhs0, lhs1, lhs2 | RHS] (where LHS =:= [lhs0, lhs1, lhs2] and the compiler refuses to do this for anything other than letter strings / lists. Theoretically, it can do this for variables, but it just doesnβt right now.
I think in your case you need to do:
Prefix = read_from_config(), TestString = "Some test string", case lists:prefix(Prefix, TestString) of true -> %% remove prefix from target string lists:nthtail(length(Prefix), TestString); false -> different_prefix end.
source share