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: search() vs. match() section should mention fullmatch() #98906

Closed
pekkaklarck opened this issue Oct 31, 2022 · 7 comments
Closed

re module: search() vs. match() section should mention fullmatch() #98906

pekkaklarck opened this issue Oct 31, 2022 · 7 comments
Labels
docs Documentation in the Doc dir topic-regex

Comments

@pekkaklarck
Copy link

pekkaklarck commented Oct 31, 2022

The docs at https://docs.python.org/3/library/re.html#search-vs-match start with

Python offers two different primitive operations based on regular expressions: re.match() checks for a match only at the beginning of the string, while re.search() checks for a match anywhere in the string (this is what Perl does by default).

but there has been re.fullmatch() since Python 3.4. I believe the third method should be mentioned and should get its own examples as well.

@pekkaklarck pekkaklarck added the docs Documentation in the Doc dir label Oct 31, 2022
@pekkaklarck pekkaklarck changed the title re module: search() vs. match() should should mention fullmatch() re module: search() vs. match() section should mention fullmatch() Oct 31, 2022
@ericvsmith
Copy link
Member

That seems like a good idea. Just this week I was looking at search vs. match, and completely forgot about fullmatch.

@ramvikrams
Copy link
Contributor

Can I add the re.fullmatch() and it's examples

ramvikrams added a commit to ramvikrams/cpython that referenced this issue Oct 31, 2022
adding re.fullmatch with it's examples
@pekkaklarck
Copy link
Author

Great that there's interest enhancing this! One thing to decide is should the section header be changed or not. Mentioning only search and match when there's also fullmatch would be odd, but the change would break possible internal and external links to this section. Internal links can be fixed as part of this change, though, and external ones can be preserved by adding an explicit link target with the old name. What approach has been used in this kind of situations earlier?

@akulakov
Copy link
Contributor

akulakov commented Nov 1, 2022

I think it's fine to keep the section name, especially as fullmatch is a variant of match().

@rhettinger
Copy link
Contributor

+1

I would also like fullmatch become better known.

That said, a cross-reference between the two entries doesn't make sense. The entries are already adjacent to one another. And we don't want to get into the business of stylistic nudging by having one feature "advertise" another.

Instead, it would be better to beef up the examples to show off fullmatch. Also the text for match and fullmatch should be expanded to draw a distinction between the them. We already have verbiage about being different from a zero-length match. There should be further wording to highlight how match and fullmatch differ from one another.

ericvsmith pushed a commit that referenced this issue Nov 30, 2022
…ention ```fullmatch()``` (GH-98916)

Mention fullmatch along with search and match.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 30, 2022
…ould mention ```fullmatch()``` (pythonGH-98916)

Mention fullmatch along with search and match.
(cherry picked from commit e0f91de)

Co-authored-by: ram vikram singh <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 30, 2022
…ould mention ```fullmatch()``` (pythonGH-98916)

Mention fullmatch along with search and match.
(cherry picked from commit e0f91de)

Co-authored-by: ram vikram singh <[email protected]>
@ericvsmith
Copy link
Member

Thanks, @ramvikrams !

ericvsmith pushed a commit that referenced this issue Nov 30, 2022
…hould mention ```fullmatch()``` (GH-98916) (GH-99912)

GH-98906 ```re``` module: ```search() vs. match()``` section should mention ```fullmatch()``` (GH-98916)

Mention fullmatch along with search and match.
(cherry picked from commit e0f91de)

Co-authored-by: ram vikram singh <[email protected]>

Co-authored-by: ram vikram singh <[email protected]>
ericvsmith pushed a commit that referenced this issue Nov 30, 2022
…hould mention ```fullmatch()``` (GH-98916) (GH-99913)

GH-98906 ```re``` module: ```search() vs. match()``` section should mention ```fullmatch()``` (GH-98916)

Mention fullmatch along with search and match.
(cherry picked from commit e0f91de)

Co-authored-by: ram vikram singh <[email protected]>

Co-authored-by: ram vikram singh <[email protected]>
@ramvikrams
Copy link
Contributor

Thanks, @ramvikrams !

Thanks sir

carljm added a commit to carljm/cpython that referenced this issue Dec 1, 2022
* main: (112 commits)
  pythongh-99894: Ensure the local names don't collide with the test file in traceback suggestion error checking (python#99895)
  pythongh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (pythonGH-99613)
  Doc: Add summary line to isolation_level & autocommit sqlite3.connect params (python#99917)
  pythonGH-98906 ```re``` module: ```search() vs. match()``` section should mention ```fullmatch()``` (pythonGH-98916)
  pythongh-89189: More compact range iterator (pythonGH-27986)
  bpo-47220: Document the optional callback parameter of weakref.WeakMethod (pythonGH-25491)
  pythonGH-99905: Fix output of misses in summarize_stats.py execution counts (pythonGH-99906)
  pythongh-99845: PEP 670: Convert PyObject macros to functions (python#99850)
  pythongh-99845: Use size_t type in __sizeof__() methods (python#99846)
  pythonGH-99877)
  Fix typo in exception message in `multiprocessing.pool` (python#99900)
  pythongh-87092: move all localsplus preparation into separate function called from assembler stage (pythonGH-99869)
  pythongh-99891: Fix infinite recursion in the tokenizer when showing warnings (pythonGH-99893)
  pythongh-99824: Document that sqlite3.connect implicitly open a transaction if autocommit=False (python#99825)
  pythonGH-81057: remove static state from suggestions.c (python#99411)
  Improve zip64 limit error message (python#95892)
  pythongh-98253: Break potential reference cycles in external code worsened by typing.py lru_cache (python#98591)
  pythongh-99127: Allow some features of syslog to the main interpreter only (pythongh-99128)
  pythongh-82836: fix private network check (python#97733)
  Docs: improve accuracy of socketserver reference (python#24767)
  ...
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 topic-regex
Projects
None yet
Development

No branches or pull requests

6 participants