Sample code for 30+ languages & platforms
Perl

StringBuilder GetNth

Demonstrates the GetNth method.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

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

my $sb = Chilkat2::StringBuilder->new;
$sb->Append('red,blue,"green,purple",,yellow');

my $delimiterChar = ',';
my $exceptDoubleQuoted = 1;
my $exceptEscaped = 1;

# Prints "[red]"
print '[', $sb->GetNth(0, $delimiterChar, $exceptDoubleQuoted, $exceptEscaped), "]\n";

# Prints "[blue]"
print '[', $sb->GetNth(1, $delimiterChar, $exceptDoubleQuoted, $exceptEscaped), "]\n";

# Prints "[green,purple]"
print '[', $sb->GetNth(2, $delimiterChar, $exceptDoubleQuoted, $exceptEscaped), "]\n";

# Prints "[]"
print '[', $sb->GetNth(3, $delimiterChar, $exceptDoubleQuoted, $exceptEscaped), "]\n";

# Prints "[yellow]"
print '[', $sb->GetNth(4, $delimiterChar, $exceptDoubleQuoted, $exceptEscaped), "]\n";

# Prints "[]"
print '[', $sb->GetNth(5, $delimiterChar, $exceptDoubleQuoted, $exceptEscaped), "]\n";