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

Erlang Binary binary_part Method

Erlang Binary Files

This method is used to extract a part of the binary string.

Syntax

binary_part(bitstring,{startposition,len})

Parameters

  • bitstring −This is the bitstring that needs to be split.

  • startposition −This is the index position of the substring starting from it.

  • len −This is the length of the substring.

Return Value

Return Substring.

-module(helloworld). 
-export([start/0]). 
start() -> 
   io:fwrite("~p~n",[binary_part(<<1,2,3,4,5>>,{0,2}).

Output Result

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

<<1,2>>

Erlang Binary Files