Method
GLibRegexmatch_all_full
since: 2.14
Declaration [src]
gboolean
g_regex_match_all_full (
const GRegex* regex,
const gchar* string,
gssize string_len,
gint start_position,
GRegexMatchFlags match_options,
GMatchInfo** match_info,
GError** error
)
Description [src]
Using the standard algorithm for regular expression matching only
the longest match in the string is retrieved, it is not possible
to obtain all the available matches. For instance matching
"<a> <b> <c>" against the pattern "<.*>"
you get "<a> <b> <c>".
This function uses a different algorithm (called DFA, i.e. deterministic
finite automaton), so it can retrieve all the possible matches, all
starting at the same point in the string. For instance matching
"<a> <b> <c>" against the pattern "<.*>"
you would obtain three matches: "<a> <b> <c>",
"<a> <b>" and "<a>".
The number of matched strings is retrieved using
g_match_info_get_match_count(). To obtain the matched strings and
their position you can use, respectively, g_match_info_fetch() and
g_match_info_fetch_pos(). Note that the strings are returned in
reverse order of length; that is, the longest matching string is
given first.
Note that the DFA algorithm is slower than the standard one and it is not able to capture substrings, so backreferences do not work.
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”.
Unless G_REGEX_RAW is specified in the options, string must be valid UTF-8.
A GMatchInfo 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 GMatchInfo internally. If
you use any GMatchInfo method (except g_match_info_free()) after
freeing or modifying string then the behaviour is undefined.
Available since: 2.14
Parameters
string-
Type: An array of
gcharThe string to scan for matches.
The length of the array is specified in the string_lenargument.The data is owned by the caller of the method. Each element is a NUL terminated UTF-8 string. string_len-
Type:
gssizeThe length of
string, in bytes, or -1 ifstringis nul-terminated. start_position-
Type:
gintStarting index of the string to match, in bytes.
match_options-
Type:
GRegexMatchFlagsMatch options.
match_info-
Type:
GMatchInfoPointer to location where to store the
GMatchInfo, orNULLif you do not need it.The argument will be set by the function. The argument can be NULL.The caller of the method takes ownership of the returned data, and is responsible for freeing it. 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 aNULLGError*.The argument will be left initialized to NULLby 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.