GRegex: add g_regex_get_max_lookbehind()

It is useful for multi-segment regex matching.

A unit test is included.

https://bugzilla.gnome.org/show_bug.cgi?id=689794
This commit is contained in:
Sébastien Wilmet
2013-07-15 13:52:14 +02:00
parent d9e01e0c37
commit 6fbb146342
4 changed files with 45 additions and 0 deletions

View File

@@ -1519,6 +1519,29 @@ g_regex_get_has_cr_or_lf (const GRegex *regex)
return !!value;
}
/**
* g_regex_get_max_lookbehind:
* @regex: a #GRegex structure
*
* Gets the number of characters in the longest lookbehind assertion in the
* pattern. This information is useful when doing multi-segment matching using
* the partial matching facilities.
*
* Returns: the number of characters in the longest lookbehind assertion.
*
* Since: 2.38
*/
gint
g_regex_get_max_lookbehind (const GRegex *regex)
{
gint max_lookbehind;
pcre_fullinfo (regex->pcre_re, regex->extra,
PCRE_INFO_MAXLOOKBEHIND, &max_lookbehind);
return max_lookbehind;
}
/**
* g_regex_get_compile_flags:
* @regex: a #GRegex