classification
Title: Exact matching
Type: feature request Stage:
Components: Regular Expressions Versions: Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: niemeyer Nosy List: loewis, niemeyer, timehorse, tlynn (4)
Priority: normal Keywords

Created on 2007-04-27 11:35 by tlynn, last changed 2008-10-13 14:46 by tlynn.

Messages (4)
msg55094 - (view) Author: Tom Lynn (tlynn) Date: 2007-04-27 11:35
I'd like to see a regexp.exact() method on regexp objects, equivalent to regexp.search(r'\A%s\Z' % pattern, ...), for parsing binary formats.

It's probably not worth disturbing the current library interface for, but maybe in Py3k?
msg55095 - (view) Author: Martin v. Löwis (loewis) Date: 2007-05-01 15:42
Moving to the feature requests tracker.

Notice that in Py3k, the string type will be a Unicode type, so it's not clear to me that regular expressions on binary data will still be supported.
msg74685 - (view) Author: Jeffrey C. Jacobs (timehorse) Date: 2008-10-13 13:31
Binary format searches should be supported once issue 1282 is implemented, 
likely as part of issue 2636 Item 32.  That said, I'm not clear what you 
mean by exact search; wouldn't you want match instead?  If your main issue 
is you want something that automatically binds to the beginning and ending 
of input, then I suppose we could add an 'exact' method where 'search' 
searches anywhere, 'match' matches from the start of input and 'exact' 
matches from beginning to ending.  I'd call that a separate issue, though.  
In other words: byte-oriented matches is covered by 1282 and adding an 
'exact' method is the only new issue here.  Does that sound right?
msg74688 - (view) Author: Tom Lynn (tlynn) Date: 2008-10-13 14:46
Yes, that's right. The binary aspect of it was something of a red
herring, I'm afraid, although I still think that (or parsing in general)
is an important use case. The prime motivation it that it's easy to
either forget the '\Z' or to use '$' instead, which both cause subtle
bugs. An exact() method might help to avoid that.
History
Date User Action Args
2008-10-13 14:46:41tlynnsetmessages: + msg74688
2008-10-13 13:31:13timehorsesetmessages: + msg74685
2008-09-28 19:31:24timehorsesetnosy: + timehorse
versions: + Python 2.7
2007-04-27 11:35:43tlynncreate