English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This method returns the index position of a substring in a string.
str(str1,str2)
str1 −This is the string that needs to be searched.
Chr1 −This is the character that needs to be searched in the string.
Return the index position of a character in a string.
-module(helloworld). -import(string,[str/2]). -export([start/ start() -> Str1 = "hello World", Index1 = str(Str1,"hello"), io:fwrite("~p~n",[Index1]).
When we run the above program, we will get the following result.
1