Sample code for 30+ languages & platforms
Xbase++

StringBuilder GetNth

Demonstrates the GetNth method.

Chilkat Xbase++ Downloads

Xbase++
LOCAL oSb
LOCAL cDelimiterChar
LOCAL nExceptDoubleQuoted
LOCAL nExceptEscaped

//  The GetNth method is handy for getting parts from delimited strings.
//  For example:

oSb := CreateObject("Chilkat.StringBuilder")
oSb:Append('red,blue,"green,purple",,yellow')

cDelimiterChar := ","
nExceptDoubleQuoted := 1
nExceptEscaped := 1

//  Prints "[red]"
? "[" + oSb:GetNth(0, cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped) + "]"

//  Prints "[blue]"
? "[" + oSb:GetNth(1, cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped) + "]"

//  Prints "[green,purple]"
? "[" + oSb:GetNth(2, cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped) + "]"

//  Prints "[]"
? "[" + oSb:GetNth(3, cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped) + "]"

//  Prints "[yellow]"
? "[" + oSb:GetNth(4, cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped) + "]"

//  Prints "[]"
? "[" + oSb:GetNth(5, cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped) + "]"

oSb:destroy()