Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re module documentation on search/match is unclear #44389

Closed
richardb mannequin opened this issue Dec 31, 2006 · 3 comments
Closed

re module documentation on search/match is unclear #44389

richardb mannequin opened this issue Dec 31, 2006 · 3 comments
Assignees
Labels
docs Documentation in the Doc dir

Comments

@richardb
Copy link
Mannequin

richardb mannequin commented Dec 31, 2006

BPO 1625381
Nosy @freddrake, @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/freddrake'
closed_at = <Date 2007-08-23.21:36:17.560>
created_at = <Date 2006-12-31.16:42:04.000>
labels = ['docs']
title = 're module documentation on search/match is unclear'
updated_at = <Date 2007-08-23.21:36:17.558>
user = 'https://bugs.python.org/richardb'

bugs.python.org fields:

activity = <Date 2007-08-23.21:36:17.558>
actor = 'georg.brandl'
assignee = 'fdrake'
closed = True
closed_date = <Date 2007-08-23.21:36:17.560>
closer = 'georg.brandl'
components = ['Documentation']
creation = <Date 2006-12-31.16:42:04.000>
creator = 'richardb'
dependencies = []
files = []
hgrepos = []
issue_num = 1625381
keywords = []
message_count = 3.0
messages = ['30885', '30886', '55223']
nosy_count = 4.0
nosy_names = ['fdrake', 'georg.brandl', 'collinwinter', 'richardb']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1625381'
versions = []

@richardb
Copy link
Mannequin Author

richardb mannequin commented Dec 31, 2006

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."

@richardb richardb mannequin assigned freddrake Dec 31, 2006
@richardb richardb mannequin added the docs Documentation in the Doc dir label Dec 31, 2006
@richardb richardb mannequin assigned freddrake Dec 31, 2006
@richardb richardb mannequin added the docs Documentation in the Doc dir label Dec 31, 2006
@collinwinter
Copy link
Mannequin

collinwinter mannequin commented Mar 9, 2007

+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?

@birkenfeld
Copy link
Member

Clarified in rev. 57354.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

No branches or pull requests

2 participants