English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang 字符串 str 方法

Erlang 字符串

该方法返回字符串中子字符串的索引位置。

语法

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

当我们运行上面的程序时,我们将得到以下结果。

1

Erlang 字符串