classification
Title: re module documentation on search/match is unclear
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: collinwinter, fdrake, georg.brandl, richardb
Priority: normal Keywords:

Created on 2006-12-31 16:42 by richardb, last changed 2007-08-23 21:36 by georg.brandl. This issue is now closed.

Messages (3)
msg30885 - (view) Author: Richard Boulton (richardb) Date: 2006-12-31 16:42
Section 4.2.2 ("Matching vs Searching") of the Python Library Reference covers the match and search methods of regular expression objects.  However, it doesn't begin by describing the difference between these methods.  Each time I try to remember which way round match and search are, it takes several minutes of checking the documentation to work out which is which. I suggest that the first paragraph of the section is replaced with the following text (in two paragraphs), to make the distinction between the methods clearer:

"Python offers two different primitive operations based on regular expressions: match and search.  match() checks for a match at the beginning of the search string, whereas search() checks for a match anywhere in the string.

If you want something equivalent to Perl's semantics, the search operation is what you're looking for. See the search() function and corresponding method of compiled regular expression objects."
msg30886 - (view) Author: Collin Winter (collinwinter) * (Python committer) Date: 2007-03-09 00:21
+1 on the general idea, though I'd change your "match() checks for a match at the beginning..." to "match() checks for a match starting at the beginning...". I'd also like to drop the reference to Perl entirely; saying that I should look to search() for Perl's semantics makes it sound like match() doesn't support PCREs.

Fred, any thoughts?
msg55223 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-08-23 21:36
Clarified in rev. 57354.
History
Date User Action Args
2007-08-23 21:36:17georg.brandlsetstatus: open -> closed
nosy: + georg.brandl
resolution: fixed
messages: + msg55223
2006-12-31 16:42:04richardbcreate