### Method

# GLib MatchInfo expand_references

since: 2.14

#### Declaration

    gchar*
    g_match_info_expand_references (
      const GMatchInfo* match_info,
      const gchar* string_to_expand,
      GError** error
    )

#### Description

Returns a new string containing the text in `string_to_expand` with references and escape sequences expanded. References refer to the last match done with `string` against `regex` and have the same syntax used by g_regex_replace().

The `string_to_expand` must be UTF-8 encoded even if `G_REGEX_RAW` was passed to g_regex_new().

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

`match_info` may be `NULL` in which case `string_to_expand` must not contain references. For instance “foo\n” does not refer to an actual pattern and ‘\n’ merely will be replaced with \n character, while to expand “\0” (whole match) one needs the result of a match. Use `g_regex_check_replacement()` to find out whether `string_to_expand` contains references.

Available since: 2.14

#### Parameters

`string_to_expand`

  Type: `const gchar*`

  The string to expand.

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

`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: `gchar*`

The expanded string, or `NULL` if an error occurred.

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