lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2015-11-07 20:05 GMT+02:00 Marco Atzori <>:
> Il 07/11/2015 18:54, Dirk Laurie ha scritto:

>> local s = tokens( "",".")

> Because 46 is the ASCII code of the dot. If I want, for example, tokenize
> the string with another character (which can be a letter, number, comma,
> semicolon, hash or any ASCII character from 1 to 255) with your code this is
> not possible because it is limited to only dot as a separator between
> tokens.
> local text = "Roses-are-red-violets-are-blue"
> As you can see, your code is unable to get "violets", when you just need
> enter 45 instead of 46.

I paid your question the compliment of actually implementing and
testing my answer. It is a disappointment that you have summarily
dismissed that answer without bothering to read it carefullly.

   s = tokens("Roses-are-red-violets-are-blue","-")

> s:gettok(4)