string:span/2
字符在字符串里的跨度范围
用法:
span(String, Chars) -> Length
内部实现:
-spec span(String, Chars) -> Length when String :: string(), Chars :: string(), Length :: non_neg_integer(). span(S, Cs) when is_list(Cs) -> span(S, Cs, 0). span([C|S], Cs, I) -> case member(C, Cs) of true -> span(S, Cs, I+1); false -> I end; span([], _Cs, I) -> I.
返回字符串 String 匹配最多字符 Chars 的长度。
string:span("aaaaabcdef", "a").
string:span("abcdef", "h").