mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 10:42:11 +01:00
regex: Add accessor to get max length of lookbehind characters
Use PCRE_INFO_MAXLOOKBEHIND to get the length (in characters) of the longest lookbehind assertion in the pattern.
This commit is contained in:
parent
37162259fd
commit
2fac72a29e
@ -1004,6 +1004,7 @@ g_regex_ref
|
||||
g_regex_unref
|
||||
g_regex_get_pattern
|
||||
g_regex_get_max_backref
|
||||
g_regex_get_max_lookbehind
|
||||
g_regex_get_capture_count
|
||||
g_regex_get_has_cr_or_lf
|
||||
g_regex_get_string_number
|
||||
|
@ -1525,6 +1525,34 @@ g_regex_get_max_backref (const GRegex *regex)
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_regex_get_max_backref:
|
||||
* @regex: a #GRegex
|
||||
*
|
||||
* Returns the lentgh of the longest lookbehind assertion in the pattern, in
|
||||
* characters. Returns <literal>0</literal> if the pattern does not
|
||||
* contain lookbehind assertions.
|
||||
*
|
||||
* This information may be useful when doing incremental partial matching; in
|
||||
* that case you should always keep at least this many characters before the
|
||||
* partially matched string.
|
||||
*
|
||||
* Returns: the length of the longest lookbehind assertion in the pattern
|
||||
*
|
||||
* Since: 2.34
|
||||
*/
|
||||
gint
|
||||
g_regex_get_max_lookbehind (const GRegex *regex)
|
||||
{
|
||||
gint value;
|
||||
|
||||
pcre_fullinfo (regex->pcre_re, regex->extra,
|
||||
PCRE_INFO_MAXLOOKBEHIND, &value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_regex_get_capture_count:
|
||||
* @regex: a #GRegex
|
||||
|
@ -449,6 +449,7 @@ GRegex *g_regex_ref (GRegex *regex);
|
||||
void g_regex_unref (GRegex *regex);
|
||||
const gchar *g_regex_get_pattern (const GRegex *regex);
|
||||
gint g_regex_get_max_backref (const GRegex *regex);
|
||||
gint g_regex_get_max_lookbehind (const GRegex *regex);
|
||||
gint g_regex_get_capture_count (const GRegex *regex);
|
||||
gboolean g_regex_get_has_cr_or_lf (const GRegex *regex);
|
||||
gint g_regex_get_string_number (const GRegex *regex,
|
||||
|
Loading…
x
Reference in New Issue
Block a user