Method

GLibMatchInfofetch_all

since: 2.14

Declaration

gchar**
g_match_info_fetch_all (
  const GMatchInfo* match_info
)

Description

Bundles up pointers to each of the matching substrings from a match and stores them in an array of gchar pointers. The first element in the returned array is the match number 0, i.e. the entire matched text.

If a sub pattern didn’t match anything (e.g. sub pattern 1, matching “b” against “(a)?b”) then an empty string is inserted.

If the last match was obtained using the DFA algorithm, that is using g_regex_match_all() or g_regex_match_all_full(), the retrieved strings are not that matched by sets of parentheses but that of the matched substring. Substrings are matched in reverse order of length, so the first one is the longest match.

The strings are fetched from the string passed to the match function, so you cannot call this function after freeing the string.

Available since: 2.14

Return value

Type: An array of utf8

A NULL-terminated array of gchar * pointers. It must be freed using g_strfreev(). If the previous match failed NULL is returned.

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