From 6ef3ed62e48d3620b06e6739ab266d72a80f090a Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 11 Apr 2014 21:15:41 +0300 Subject: [PATCH] re-pcre: Capture all possible subexpressions, even empty. --- re-pcre/re.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/re-pcre/re.py b/re-pcre/re.py index 833b8d94..f599f47b 100644 --- a/re-pcre/re.py +++ b/re-pcre/re.py @@ -67,7 +67,9 @@ class PCREPattern: if num == -1: # No match return None - return PCREMatch(s, num, ov) + # We don't care how many matching subexpressions we got, we + # care only about total # of capturing ones (including empty) + return PCREMatch(s, cap_count + 1, ov) def match(self, s, pos=0, endpos=-1): return self.search(s, pos, endpos, PCRE_ANCHORED)