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

Erlang String str Method

Erlang String

This method returns the index position of a substring in a string.

Syntax

str(str1,str2)

Parameter

  • str1 −This is the string that needs to be searched.

  • Chr1 −This is the character that needs to be searched in the string.

Return Value

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

Erlang String