Logo

Programming-Idioms

History of Idiom 46 > diff from v24 to v25

Edit summary for version 25 by :
New Erlang implementation by user [elbrujohalcon]

Version 24

2015-12-18, 02:49:37

Version 25

2015-12-18, 02:53:31

Idiom #46 Extract beginning of string (prefix)

Create string t consisting of the 5 first characters of string s.

Idiom #46 Extract beginning of string (prefix)

Create string t consisting of the 5 first characters of string s.

Code
T = string:sub_string(S, 1, 5),
T = string:substr(S, 1, 5).
Comments bubble
The second argument for substr is the length, for sub_string it's the last position
Doc URL
http://erldocs.com/current/stdlib/string.html?i=22&search=string:#sub_string/2
Demo URL
http://tryerl.seriyps.ru/#id=19f3