@@ -557,7 +557,7 @@ def test_anyall(self):
557557 self .assertEqual (re .match ("a.*b" , "a\n \n b" , re .DOTALL ).group (0 ),
558558 "a\n \n b" )
559559
560- def test_lookahead (self ):
560+ def test_non_consuming (self ):
561561 self .assertEqual (re .match ("(a(?=\s[^a]))" , "a b" ).group (1 ), "a" )
562562 self .assertEqual (re .match ("(a(?=\s[^a]*))" , "a b" ).group (1 ), "a" )
563563 self .assertEqual (re .match ("(a(?=\s[abc]))" , "a b" ).group (1 ), "a" )
@@ -571,42 +571,6 @@ def test_lookahead(self):
571571 self .assertEqual (re .match (r"(a)(?!\s\1)" , "a b" ).group (1 ), "a" )
572572 self .assertEqual (re .match (r"(a)(?!\s(abc|a))" , "a b" ).group (1 ), "a" )
573573
574- # Group reference.
575- self .assertTrue (re .match (r'(a)b(?=\1)a' , 'aba' ))
576- self .assertIsNone (re .match (r'(a)b(?=\1)c' , 'abac' ))
577- # Conditional group reference.
578- self .assertTrue (re .match ('(?:(a)|(x))b(?=(?(2)x|c))c' , 'abc' ))
579- self .assertIsNone (re .match ('(?:(a)|(x))b(?=(?(2)c|x))c' , 'abc' ))
580- self .assertTrue (re .match ('(?:(a)|(x))b(?=(?(2)x|c))c' , 'abc' ))
581- self .assertIsNone (re .match ('(?:(a)|(x))b(?=(?(1)b|x))c' , 'abc' ))
582- self .assertTrue (re .match ('(?:(a)|(x))b(?=(?(1)c|x))c' , 'abc' ))
583- # Group used before defined.
584- self .assertTrue (re .match ('(a)b(?=(?(2)x|c))(c)' , 'abc' ))
585- self .assertIsNone (re .match ('(a)b(?=(?(2)b|x))(c)' , 'abc' ))
586- self .assertTrue (re .match ('(a)b(?=(?(1)c|x))(c)' , 'abc' ))
587-
588- def test_lookbehind (self ):
589- self .assertTrue (re .match ('ab(?<=b)c' , 'abc' ))
590- self .assertIsNone (re .match ('ab(?<=c)c' , 'abc' ))
591- self .assertIsNone (re .match ('ab(?<!b)c' , 'abc' ))
592- self .assertTrue (re .match ('ab(?<!c)c' , 'abc' ))
593- # Group reference.
594- self .assertTrue (re .match (r'(a)a(?<=\1)c' , 'aac' ))
595- self .assertIsNone (re .match (r'(a)b(?<=\1)a' , 'abaa' ))
596- self .assertIsNone (re .match (r'(a)a(?<!\1)c' , 'aac' ))
597- self .assertTrue (re .match (r'(a)b(?<!\1)a' , 'abaa' ))
598- # Conditional group reference.
599- self .assertIsNone (re .match ('(?:(a)|(x))b(?<=(?(2)x|c))c' , 'abc' ))
600- self .assertIsNone (re .match ('(?:(a)|(x))b(?<=(?(2)b|x))c' , 'abc' ))
601- self .assertTrue (re .match ('(?:(a)|(x))b(?<=(?(2)x|b))c' , 'abc' ))
602- self .assertIsNone (re .match ('(?:(a)|(x))b(?<=(?(1)c|x))c' , 'abc' ))
603- self .assertTrue (re .match ('(?:(a)|(x))b(?<=(?(1)b|x))c' , 'abc' ))
604- # Group used before defined.
605- self .assertIsNone (re .match ('(a)b(?<=(?(2)x|c))(c)' , 'abc' ))
606- self .assertIsNone (re .match ('(a)b(?<=(?(2)b|x))(c)' , 'abc' ))
607- self .assertIsNone (re .match ('(a)b(?<=(?(1)c|x))(c)' , 'abc' ))
608- self .assertTrue (re .match ('(a)b(?<=(?(1)b|x))(c)' , 'abc' ))
609-
610574 def test_ignore_case (self ):
611575 self .assertEqual (re .match ("abc" , "ABC" , re .I ).group (0 ), "ABC" )
612576 self .assertEqual (re .match (b"abc" , b"ABC" , re .I ).group (0 ), b"ABC" )
0 commit comments