English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This method returns a substring of the original string based on the starting position and the number of characters at the starting position.
substr(str1,start,number)
str1 −This is the string from which the substring needs to be extracted.
Start −This is the starting position from which the substring should start.
Number −This is the number of characters that need to appear in the substring.
Returns a substring from the original string based on the starting position and length.
-module(helloworld). -import(string,[substr/3]). -export([start/0]). start() -> Str1 = "hello World", Str2 = substr(Str1,2,5), io:fwrite("~p~n",[Str2]).
When we run the above program, we will get the following result.
"ello"