[erlang-questions] substr and sub_str ??

Jesper Louis Andersen <>
Tue Jul 27 19:28:58 CEST 2010


On Tue, Jul 27, 2010 at 7:15 PM, Wes James <> wrote:
> I'm just curious as to why in:
>
> http://www.erlang.org/doc/man/string.html
>
> there is substr and sub_string - they look indentical?

They are subtly different if given the 3rd argument. We have

substr(S, Start, Length)

and

sub_string(S, Start, Stop)

And the rule which governs their difference is that Stop = Start +
Length - 1 (If I can compute in my head). The examples in the
documentation tells more.

-- 
J.


More information about the erlang-questions mailing list