Method

GLibStringreplace

since: 2.68

Declaration

guint
g_string_replace (
  GString* string,
  const gchar* find,
  const gchar* replace,
  guint limit
)

Description

Replaces the string find with the string replace in a GString up to limit times. If the number of instances of find in the GString is less than limit, all instances are replaced. If limit is 0, all instances of find are replaced.

If find is the empty string, since versions 2.69.1 and 2.68.4 the replacement will be inserted no more than once per possible position (beginning of string, end of string and between characters). This did not work correctly in earlier versions.

Available since: 2.68

Parameters

find

Type: const gchar*

The string to find in string.

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

Type: const gchar*

The string to insert in place of find.

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

Type: guint

The maximum instances of find to replace with replace, or 0 for no limit.

Return value

Type: guint

The number of find and replace operations performed.