Str.strsplitSet

Splits @string into a number of tokens not containing any of the characters in @delimiter. A token is the (possibly empty) longest string that does not contain any of the characters in @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 a %NULL-terminated vector containing the three strings "abc", "def", and "ghi".

The result of g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated vector containing the four strings "", "def", "ghi", and "".

As a special case, the result of splitting the empty string "" is an empty vector, not a vector containing a single string. The reason for this special case is that being able to represent an empty vector 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.

struct Str
static
string[]
strsplitSet
(
string string_
,
string delimiters
,)

Parameters

string_ string

The string to be tokenized

delimiters string

A nul-terminated string containing bytes that are used to split the string (it can accept an empty string, which will result in no string splitting).

maxTokens int

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

Return Value

Type: string[]

a newly-allocated %NULL-terminated array of strings. Use g_strfreev() to free it.

Meta