Lua
Lua
StringBuilder GetNth
Demonstrates the GetNth method.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- The GetNth method is handy for getting parts from delimited strings.
-- For example:
local sb = chilkat.StringBuilder.new()
sb:append("red,blue,\"green,purple\",,yellow")
local delimiterChar = ","
local exceptDoubleQuoted = true
local exceptEscaped = true
-- Prints "[red]"
print("[" .. sb:get_nth(0, delimiterChar, exceptDoubleQuoted, exceptEscaped) .. "]")
-- Prints "[blue]"
print("[" .. sb:get_nth(1, delimiterChar, exceptDoubleQuoted, exceptEscaped) .. "]")
-- Prints "[green,purple]"
print("[" .. sb:get_nth(2, delimiterChar, exceptDoubleQuoted, exceptEscaped) .. "]")
-- Prints "[]"
print("[" .. sb:get_nth(3, delimiterChar, exceptDoubleQuoted, exceptEscaped) .. "]")
-- Prints "[yellow]"
print("[" .. sb:get_nth(4, delimiterChar, exceptDoubleQuoted, exceptEscaped) .. "]")
-- Prints "[]"
print("[" .. sb:get_nth(5, delimiterChar, exceptDoubleQuoted, exceptEscaped) .. "]")