該方法返回字符串中子字符串的索引位置。
str(str1,str2)
str1 ?這是需要搜索的字符串。
Chr1 ?這是需要在字符串中搜索的字符。
返回字符串中字符的索引位置。
-module(helloworld).
-import(string,[str/2]).
-export([start/0]).
start() ->
Str1 = "hello World",
Index1 = str(Str1,"hello"),
io:fwrite("~p~n",[Index1]).當(dāng)我們運(yùn)行上面的程序時(shí),我們將得到以下結(jié)果。
1