学习erlang,并对我在以下代码中尝试做的事情感到困惑:
start() ->
Lst = string:tokens("Hello,How,Are,You!Today",",!"),
Result = [string:substr(Lst, ".!", len(Lst))],
Result.
我收到以下错误:异常错误:没有匹配字符串的函数子句:substr([“Hello”,“How”,“Are”,“You”,“Today”],“。!”,5)< / p>
答案 0 :(得分:0)
string:substr/3
在第二个和第三个参数中使用整数:
10> [string:substr(Lst, 1, length(Lst))].
[["Hello","How","Are","You","Today"]]
11> [string:substr(Lst, 3, length(Lst))].
[["Are","You","Today"]]
你传递字符串".!"
作为第二个参数,这就是你得到一个函数子句错误的原因。