Method

GLibRegexsplit_full

since: 2.14

Declaration [src]

gchar**
g_regex_split_full (
  const GRegex* regex,
  const gchar* string,
  gssize string_len,
  gint start_position,
  GRegexMatchFlags match_options,
  gint max_tokens,
  GError** error
)

Description [src]

Breaks the string on the pattern, and returns an array of the tokens. If the pattern contains capturing parentheses, then the text for each of the substrings will also be returned. If the pattern does not match anywhere in the string, then the whole string is returned as the first token.

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 this function.

A pattern that can match empty strings splits string into separate characters wherever it matches the empty string between characters. For example splitting “ab c” using as a separator “\s*”, you will get “a”, “b” and “c”.

Setting start_position differs from just passing over a shortened string and setting G_REGEX_MATCH_NOTBOL in the case of a pattern that begins with any kind of lookbehind assertion, such as “\b”.

Available since: 2.14

Parameters

string

Type: An array of gchar

The string to split with the pattern.

The length of the array is specified in the string_len argument.
The data is owned by the caller of the method.
Each element is a NUL terminated UTF-8 string.
string_len

Type: gssize

The length of string, in bytes, or -1 if string is nul-terminated.

start_position

Type: gint

Starting index of the string to match, in bytes.

match_options

Type: GRegexMatchFlags

Match time option flags.

max_tokens

Type: gint

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

error

Type: GError **

The return location for a recoverable error.

The argument can be NULL.
If the return location is not NULL, then you must initialize it to a NULL GError*.
The argument will be left initialized to NULL by the method if there are no errors.
In case of error, the argument will be set to a newly allocated GError; the caller will take ownership of the data, and be responsible for freeing it.

Return value

Type: An array of utf8

A NULL-terminated gchar ** array. Free it using g_strfreev().

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