GLib.Regex.prototype.split

function split(string: String, match_options: GLib.RegexMatchFlags): Array(String) {
    // Gjs wrapper for g_regex_split()
}
  

Breaks the string on the pattern, and returns an array of the tokens. If the pattern contains capturing parentheses, then the text for each of the substrings will also be returned. If the pattern does not match anywhere in the string, then the whole string is returned as the first token.

As a special case, the result of splitting the empty string "" is an empty vector, not a vector containing a single string. The reason for this special case is that being able to represent a empty vector is typically more useful than consistent handling of empty elements. If you do need to represent empty elements, you'll need to check for the empty string before calling this function.

A pattern that can match empty strings splits string into separate characters wherever it matches the empty string between characters. For example splitting "ab c" using as a separator "\s*", you will get "a", "b" and "c".

Since 2.14

string

the string to split with the pattern

match_options

match time option flags

Returns

a null-terminated gchar ** array. Free it using GLib.strfreev