Sample code for 30+ languages & platforms
React Native

StringBuilder GetNth

Demonstrates the GetNth method.

Chilkat React Native Downloads

React Native
import { StringBuilder } from '@chilkat/react-native'

function chilkatExample() {
  // The GetNth method is handy for getting parts from delimited strings.
  // For example:

  const sb = new StringBuilder();
  sb.append('red,blue,"green,purple",,yellow');

  const delimiterChar = ',';
  const exceptDoubleQuoted = true;
  const exceptEscaped = true;

  // Prints "[red]"
  console.log(`[${sb.getNth(0, delimiterChar, exceptDoubleQuoted, exceptEscaped)}]`);

  // Prints "[blue]"
  console.log(`[${sb.getNth(1, delimiterChar, exceptDoubleQuoted, exceptEscaped)}]`);

  // Prints "[green,purple]"
  console.log(`[${sb.getNth(2, delimiterChar, exceptDoubleQuoted, exceptEscaped)}]`);

  // Prints "[]"
  console.log(`[${sb.getNth(3, delimiterChar, exceptDoubleQuoted, exceptEscaped)}]`);

  // Prints "[yellow]"
  console.log(`[${sb.getNth(4, delimiterChar, exceptDoubleQuoted, exceptEscaped)}]`);

  // Prints "[]"
  console.log(`[${sb.getNth(5, delimiterChar, exceptDoubleQuoted, exceptEscaped)}]`);
}