[issue13998] Lookbehind assertions go behind the start position for the match
Ezio Melotti ezio.melo...@gmail.com added the comment: IMHO the documentation is fine as is. Using pos in combination with lookarounds that match on the beginning/end of the slice seems a rather uncommon corner case, and I don't think it's worth documenting it. Even if it was documented, as a user, I would just try it from the interpreter anyway, rather than checking the docs for some prose to decipher. -- assignee: - docs@python components: +Documentation nosy: +docs@python resolution: - wont fix stage: - committed/rejected status: open - closed versions: +Python 3.3 -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13998] Lookbehind assertions go behind the start position for the match
Matthew Barnett pyt...@mrabarnett.plus.com added the comment: The documentation says of the 'pos' parameter This is not completely equivalent to slicing the string and of the 'endpos' parameter it will be as if the string is endpos characters long. In other words, it starts searching at 'pos' but truncates at 'endpos'. Yes, it's inconsistent, but it's documented. -- nosy: +mrabarnett ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13998] Lookbehind assertions go behind the start position for the match
Devin Jeanpierre jeanpierr...@gmail.com added the comment: If it's intended behaviour, then I'd request that the documentation specifically mention lookbehind assertions the way it does with ^. Saying it's slightly different doesn't make clear the ways in which it is different, and that's important for people writing or using regular expressions. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13998] Lookbehind assertions go behind the start position for the match
New submission from Devin Jeanpierre jeanpierr...@gmail.com: compiled regex objects' match method offers an optional pos parameter described to be roughly equivalent to slicing except for how it treats the ^ operation. See http://docs.python.org/library/re.html#re.RegexObject.search However, the behavior of lookbehind assertions also differs: re.compile((?=a)b).match(ab, 1) _sre.SRE_Match object at 0x... re.compile((?=a)b).match(ab[1:]) This alone might be a documentation bug, but the behavior is also inconsistent with the behavior of lookahead assertions, which do *not* look past the endpos: re.compile(a(?=b)).match(ab, 0, 1) re.compile(a(?=b)).match(ab) _sre.SRE_Match object at 0x... -- components: Regular Expressions messages: 153188 nosy: Devin Jeanpierre, ezio.melotti priority: normal severity: normal status: open title: Lookbehind assertions go behind the start position for the match type: behavior versions: Python 2.7, Python 3.1, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com