cpython: 9fcf4008b626 (original) (raw)

Mercurial > cpython

changeset 93434:9fcf4008b626 3.4

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:57 +0200
parents 8b1d8fcb494b
children 60fccf0aad83 246c9570a757
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 @@ -352,10 +352,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 @@ -181,7 +182,21 @@ class SubPattern: elif op in UNITCODES: lo = lo + 1 hi = hi + 1

@@ -709,7 +724,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 @@ -557,7 +557,7 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match("a.*b", "a\n\nb", re.DOTALL).group(0), "a\n\nb")

@@ -571,6 +571,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(b"abc", b"ABC", re.I).group(0), b"ABC")

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