cpython: fac649bf2d10 (original) (raw)

Mercurial > cpython

changeset 93433:fac649bf2d10 2.7

Issues #814253, #9179: Group references and conditional group references now work in lookbehind assertions in regular expressions. [#814253]

Serhiy Storchaka storchaka@gmail.com
date Fri, 07 Nov 2014 21:43:45 +0200
parents 7b82b58b8329
children 0e2c7d774df3
files Lib/re.py Lib/sre_parse.py Lib/test/test_re.py Misc/NEWS
diffstat 4 files changed, 67 insertions(+), 12 deletions(-)[+] [-] Lib/re.py 5 Lib/sre_parse.py 33 Lib/test/test_re.py 38 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/re.py +++ b/Lib/re.py @@ -312,10 +312,11 @@ class Scanner: s = sre_parse.Pattern() s.flags = flags for phrase, action in lexicon:

--- a/Lib/sre_parse.py +++ b/Lib/sre_parse.py @@ -66,24 +66,25 @@ class Pattern: # master pattern object. keeps track of global attributes def init(self): self.flags = 0

class SubPattern: # a subpattern, in intermediate form @@ -178,7 +179,21 @@ class SubPattern: elif op in UNITCODES: lo = lo + 1 hi = hi + 1

@@ -657,7 +672,7 @@ def _parse(source, state): if not sourcematch(")"): raise error, "unbalanced parenthesis" if group is not None:

--- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -448,7 +448,7 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match("a.*b", "a\n\nb", re.DOTALL).group(0), "a\n\nb")

@@ -462,6 +462,42 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match(r"(a)(?!\s\1)", "a b").group(1), "a") self.assertEqual(re.match(r"(a)(?!\s(abc|a))", "a b").group(1), "a")

+

+ def test_ignore_case(self): self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC") self.assertEqual(re.match("abc", u"ABC", re.I).group(0), "ABC")

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -37,6 +37,9 @@ Core and Builtins Library ------- +- Issues #814253, #9179: Group references and conditional group references now