GLib.MatchInfo.fetch

### Method

# GLib MatchInfofetch

since: 2.14

#### Declaration [src]

    gchar*
    g_match_info_fetch (
      const GMatchInfo* match_info,
      gint match_num
    )

#### Description [src]

Retrieves the text matching the `match_num`‘th capturing parentheses. 0 is the full text of the match, 1 is the first paren set, 2 the second, and so on.

If `match_num` is a valid sub pattern but it didn’t match anything (e.g. sub pattern 1, matching “b” against “(a)?b”) then an empty string is returned.

If the match was obtained using the DFA algorithm, that is using `g_regex_match_all()` or g_regex_match_all_full(), the retrieved string is not that of a set of parentheses but that of a matched substring. Substrings are matched in reverse order of length, so 0 is the longest match.

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

Available since: 2.14

#### Parameters

`match_num`

  Type: `gint`

  Number of the sub expression.

#### Return value

Type: `gchar*`

The matched substring, or `NULL` if an error occurred. You have to free the string yourself.

The caller of the method takes ownership of the returned data, and is responsible for freeing it.
The return value can be `NULL`.
The value is a NUL terminated UTF-8 string.