Re: split method?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: split method?
- From: Norbert Kiesel <nkiesel@...>
- Date: 2011年6月29日 10:47:29 -0700
On Wed, 2011年06月29日 at 11:42 +0200, Valerio Schiavoni wrote:
> This is our split function:
>
>
> function split(s, sep)
> local res = {}
> sep = sep or ' '
> for v in s:gmatch('[^' .. sep .. ']+') do
> res[#res + 1] = v
> end
> return res
> end
Would make sense to throw in an assert(#sep == 1) because this fails for
e.g. split('hi[]there', '[]')
</nk>