From 42d169f374f14595c52c523b40c97dc90707c46f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 13 Jan 2017 12:26:42 +0100 Subject: text-regex: add text_regex_nsub to get number of sub expressions --- text-regex.c | 6 ++++++ text-regex.h | 1 + 2 files changed, 7 insertions(+) diff --git a/text-regex.c b/text-regex.c index dd541d7..439c24a 100644 --- a/text-regex.c +++ b/text-regex.c @@ -23,6 +23,12 @@ int text_regex_compile(Regex *regex, const char *string, int cflags) { return r; } +size_t text_regex_nsub(Regex *r) { + if (!r) + return 0; + return r->regex.re_nsub; +} + void text_regex_free(Regex *r) { if (!r) return; diff --git a/text-regex.h b/text-regex.h index 3ace3de..1b2c382 100644 --- a/text-regex.h +++ b/text-regex.h @@ -9,6 +9,7 @@ typedef Filerange RegexMatch; Regex *text_regex_new(void); int text_regex_compile(Regex*, const char *pattern, int cflags); +size_t text_regex_nsub(Regex*); void text_regex_free(Regex*); int text_regex_match(Regex*, const char *data, int eflags); int text_search_range_forward(Text*, size_t pos, size_t len, Regex *r, size_t nmatch, RegexMatch pmatch[], int eflags); -- cgit v1.2.3