str:split()

str:split() 使用模式字串分割字串,以確定分割位置,並返回包含結果字串的節點集。

語法

str:split(string, pattern)

引數

字串

要分割的字串。

模式

指示在何處分割字串的模式。

返回值

一個包含token元素的節點集,每個元素包含來自string的一個標記。

示例

str:split('book, phone, computer, chair', ', ')

返回類似於以下內容的節點集

xml
<token>book</token>
<token>phone</token>
<token>computer</token>
<token>chair</token>

規範

另請參閱