[erlang-questions] re module zero-based indices

Andrew Thompson <>
Thu Jun 4 21:08:34 CEST 2009


On Thu, Jun 04, 2009 at 04:09:06PM +1000, Bernard Duggan wrote:
> Hi all,
>     Can anyone explain to me the thinking behind making character
> indices in the re: module zero based, rather than 1 based like pretty
> much everything else in erlang?  I was just going through our code
> migrating from the old regexp: calls and it struck me as a bit
> odd/inconsistent.  It's quite likely I'm missing something obvious though...
> 
> (My apologies if this has been asked before - searching for the string
> "re" returns an awful lot of results :)).
>

I suspect its because the pcre library that re is implemented on top of
uses 0 based indices. Why the re module doesn't simply translate them, I
don't know (it's not like the stdlib is particularly consistant anyway).

Andrew


More information about the erlang-questions mailing list