[ CCode ( cname = "g_strdelimit" ) ]
public unowned string _delimit (string delimiters, char new_delimiter)

Converts any delimiter characters in string to new_delimiter.

Any characters in string which are found in delimiters are changed to the new_delimiter character. Modifies string in place, and returns string itself, not a copy.

The return value is to allow nesting such as:

  g_ascii_strup (g_strdelimit (str, "abc", '?'))

In order to modify a copy, you may use strdup:

  reformatted = g_strdelimit (g_strdup (const_str), "abc", '?');
g_free (reformatted);

Example: Replace any delimiter characters with another one (inline):

public static int main (string[] args) {
string str1 = "ABCDEFG";
unowned string str2 = str1._delimit ("ADEG", 'x');

// Output:
// ``xBCxxFx``
// ``xBCxxFx``
print ("%s\n", str1);
print ("%s\n", str2);
return 0;

valac --pkg glib-2.0 string._delimit.vala



a string containing the current delimiters, or null to use the standard delimiters defined in g_str_delimiters


the new delimiter character


the string to convert


the modified string