[issue14460] In re's positive lookbehind assertion repetition works

2014-11-01 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Pytho

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread py.user
py.user added the comment: Tim Peters wrote: > Should that raise an exception? >i += 0 >(?=a)b >(?=a)a These are another cases. The first is very special. The second and third are special too, but with different contents of assertion they can do useful work. While "(?=any contents){N}a" ne

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread Tim Peters
Tim Peters added the comment: BTW, note that the idea "successful lookaround assertions match an empty string" isn't just a figure of speech: it's the literal truth, and - indeed - is key to understanding what happens here. You can see this by adding some capturing groups around the assertio

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread Tim Peters
Tim Peters added the comment: >> (?<=a)(?<=a)(?<=a)(?<=a) > There are four different points. > If a1 before a2 and a2 before a3 and a3 before a4 and a4 > before something. Sorry, that view doesn't make any sense. A successful lookbehind assertion matches the empty string. Same as the regexp

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread py.user
py.user added the comment: Tim Peters wrote: > (?<=a)(?<=a)(?<=a)(?<=a) There are four different points. If a1 before a2 and a2 before a3 and a3 before a4 and a4 before something. Otherwise repetition of assertion has no sense. If it has no sense, there should be an exception. -- __

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread Tim Peters
Tim Peters added the comment: I would not call this a bug - it's just usually a silly thing to do ;-) Note, e.g., that p{N} is shorthand for writing p N times. For example, p{4} is much the same as (but not exactly so in all cases; e.g., if `p` happens to contain a capturing group, the n

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread Matthew Barnett
Matthew Barnett added the comment: Lookarounds can capture, but they don't consume. That lookbehind is matching the same part of the string every time. -- ___ Python tracker ___

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread py.user
py.user added the comment: >>> m = re.search(r'(?<=(a)){10}bc', 'abc', re.DEBUG) max_repeat 10 10 assert -1 subpattern 1 literal 97 literal 98 literal 99 >>> m.group() 'bc' >>> >>> m.groups() ('a',) >>> It works like there are 10 letters "a" before letter "b". -- ___

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread Matthew Barnett
Matthew Barnett added the comment: Lookarounds can contain capture groups: >>> import re >>> re.search(r'a(?=(.))', 'ab').groups() ('b',) >>> re.search(r'(?<=(.))b', 'ab').groups() ('a',) so lookarounds that are optional or can have no repeats might have a use. I'm not sure whether it's useful

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Technically this is not a bug. -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-l

[issue14460] In re's positive lookbehind assertion repetition works

2014-06-25 Thread Mark Lawrence
Mark Lawrence added the comment: Can someone comment on this regex problem please, they're just not my cup of tea. -- nosy: +BreamoreBoy versions: +Python 2.7, Python 3.4, Python 3.5 -Python 3.2 ___ Python tracker

[issue14460] In re's positive lookbehind assertion repetition works

2012-04-01 Thread py.user
New submission from py.user : >>> import re >>> re.search(r'(?<=a){100,200}bc', 'abc', re.DEBUG) max_repeat 100 200 assert -1 literal 97 literal 98 literal 99 <_sre.SRE_Match object at 0xb7429f38> >>> re.search(r'(?<=a){100,200}bc', 'abc', re.DEBUG).group() 'bc' >>> I expected "nothi