The lists:sublist function is the most general solution. lists:sublist has two forms: (a) the first takes a string and a number of entries to return, and (b) a version that takes a string, a start index (indexed from 1), and an end index. For example:
There is also a string module, which contains many more string-specific functions. To take the substring of a string, use the string:substr function. This function has two forms: (a) the first takes a string and a start index (indexed from 1), and (b) a version that takes a string, a start index (indexed from 1), and an end index. For example: