Sample code for 30+ languages & platforms
Chilkat2-Python

StringBuilder GetNth

Demonstrates the GetNth method.

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import chilkat2

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

sb = chilkat2.StringBuilder()
sb.Append("red,blue,\"green,purple\",,yellow")

delimiterChar = ","
exceptDoubleQuoted = True
exceptEscaped = True

# Prints "[red]"
print("[" + sb.GetNth(0,delimiterChar,exceptDoubleQuoted,exceptEscaped) + "]")

# Prints "[blue]"
print("[" + sb.GetNth(1,delimiterChar,exceptDoubleQuoted,exceptEscaped) + "]")

# Prints "[green,purple]"
print("[" + sb.GetNth(2,delimiterChar,exceptDoubleQuoted,exceptEscaped) + "]")

# Prints "[]"
print("[" + sb.GetNth(3,delimiterChar,exceptDoubleQuoted,exceptEscaped) + "]")

# Prints "[yellow]"
print("[" + sb.GetNth(4,delimiterChar,exceptDoubleQuoted,exceptEscaped) + "]")

# Prints "[]"
print("[" + sb.GetNth(5,delimiterChar,exceptDoubleQuoted,exceptEscaped) + "]")