### Function

# GLib strsplit_set

since: 2.4

#### Declaration [src]

    gchar**
    g_strsplit_set (
      const gchar* string,
      const gchar* delimiters,
      gint max_tokens
    )

#### Description [src]

Splits `string` into a number of tokens not containing any of the bytes in `delimiters`.

A token is the (possibly empty) longest string that does not contain any of the bytes in `delimiters`. Note that separators will only be single bytes from `delimiters`. If `max_tokens` is reached, the remainder is appended to the last token.

For example, the result of `g_strsplit_set ("abc:def/ghi", ":/", -1)` is an array containing the three strings `"abc"`, `"def"`, and `"ghi"`.

The result of `g_strsplit_set (":def/ghi:/x", ":/", -1)` is an array containing the five strings `""`, `"def"`, `"ghi"`, `""`, `"x"`.

As a special case, the result of splitting the empty string `""` is an empty array, not an array containing a single string. The reason for this special case is that being able to represent an empty array is typically more useful than consistent handling of empty elements. If you do need to represent empty elements, you’ll need to check for the empty string before calling `g_strsplit_set()`.

Note that this function works on bytes not characters, so it can’t be used to delimit UTF-8 strings for anything but ASCII characters.

Available since: 2.4

#### Parameters

`string`

  Type: `const gchar*`

  A string to split.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`delimiters`

  Type: An array of `guint8`

  A nul-terminated byte array containing bytes that are used to split the string; can be empty (just a nul byte), which will result in no string splitting.

  The array must be `NULL`-terminated.
  The data is owned by the caller of the function.

`max_tokens`

  Type: `gint`

  The maximum number of tokens to split `string` into. If this is less than 1, the string is split completely.

#### Return value

Type: An array of `utf8`

A newly-allocated array of strings. Use `g_strfreev()` to free it.

The array is `NULL`-terminated.
The caller of the function takes ownership of the data, and is responsible for freeing it.
Each element is a NUL terminated UTF-8 string.