Erlang – left

Erlang left

In this guide, we will discuss Erlang left. The method returns the sub string from the left of the string based on the number of characters.

Syntax

left(str1,number)

Parameters

  • str1 βˆ’ This is the string from which the sub string needs to be extracted.
  • Number βˆ’ This is the number of characters which need to be present in the substring.

Return Value

Returns the sub string from the original string based on the left hand side of the string and the number.

For example

-module(helloworld). 
-import(string,[left/2]). 
-export([start/0]). 

start() -> 
   Str1 = "hello World", 
   Str2 = left(Str1,2), 
   io:fwrite("~p~n",[Str2]).

Output

When we run the above program, we will get the following result.

β€œhe”

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply