The method returns the index position of a sub string in a string.
str1 − This is the string which needs to be searched.
Chr1 − This is the character which needs to be searched in the string.
Returns the index position of the character in the string.
-module(helloworld). -import(string,[str/2]). -export([start/0]). 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.