Split string into equal slices/chunks

后端 未结 1 1022
再見小時候
再見小時候 2021-01-27 05:43

I have a string of length N and I want to split it into equal parts of length L (assuming the last part might be shorter).

What I came up with

1条回答
  •  后悔当初
    2021-01-27 06:06

    What about this?

    string.scan(/.{,#{L}}/)
    

    0 讨论(0)
提交回复
热议问题