GLib.Regex.prototype.match_full
function match_full(string: Array(String), start_position: Number(gint), match_options: GLib.RegexMatchFlags): [ok: Boolean, match_info: GLib.MatchInfo] { // Gjs wrapper for g_regex_match_full() }
Scans for a match in string for the pattern in regex. The match_options are combined with the match options specified when the regex structure was created, letting you have more flexibility in reusing GLib.Regex structures.
Setting start_position differs from just passing over a shortened string and setting #G_REGEX_MATCH_NOTBOL in the case of a pattern that begins with any kind of lookbehind assertion, such as "\b".
A GLib.MatchInfo structure, used to get information on the match, is stored in match_info if not null. Note that if match_info is not null then it is created even if the function returns false, i.e. you must free it regardless if regular expression actually matched.
string is not copied and is used in GLib.MatchInfo internally. If you use any GLib.MatchInfo method (except GLib.MatchInfo.prototype.free) after freeing or modifying string then the behaviour is undefined.
To retrieve all the non-overlapping matches of the pattern in string you can use GLib.MatchInfo.prototype.next.
|[<!-- language="C" --> static void print_uppercase_words (const gchar *string) { // Print all uppercase-only words. GRegex *regex; GMatchInfo *match_info; GError *error = NULL; regex = g_regex_new ("[A-Z]+", 0, 0, NULL); g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error); while (g_match_info_matches (match_info)) { gchar *word = g_match_info_fetch (match_info, 0); g_print ("Found: %s\n", word); g_free (word); g_match_info_next (match_info, &error); } g_match_info_free (match_info); g_regex_unref (regex); if (error != NULL) { g_printerr ("Error while matching: %s\n", error->message); g_error_free (error); } } ]|
Since 2.14
- string
the string to scan for matches
- start_position
starting index of the string to match
- match_options
match options
- ok
true is the string matched, false otherwise
- match_info
pointer to location where to store the GLib.MatchInfo, or null if you do not need it