-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
GH-98906 re
module: search() vs. match()
section should mention fullmatch()
#98916
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
Changes from 1 commit
7e90e14
9a1bc61
afab961
f827986
95efa61
84fc8c8
a650b40
1ea3105
d2a6981
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
update the examples where `re.match` and `re.search` shows a match but not `re.fullmatch`
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1575,11 +1575,11 @@ Python offers different primitive operations based on regular expressions: | |
|
||
For example:: | ||
|
||
>>> re.match("c", "abcdef") # No match | ||
>>> re.search("c", "abcdef") # Match | ||
<re.Match object; span=(2, 3), match='c'> | ||
>>> re.fullmatch("python", "python") # Match | ||
<re.Match object; span=(0, 6), match='python'> | ||
>>> re.match("c", "cdef") # match | ||
<re.Match object; span=(0, 1), match='c'> | ||
>>> re.search("c", "cdef") # Match | ||
<re.Match object; span=(0, 1), match='c'> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I would not add these 2 examples. The existing examples are fine. The goal is to show that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes sir |
||
>>> re.fullmatch("c", "cdef") # No Match | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I wasn't clear. I think you need two examples for fullmatch: re.fullmatch("p.*n", "python") # Match
re.fullmatch("r.*n", "python") # No match There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes sir There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done sir |
||
|
||
Regular expressions beginning with ``'^'`` can be used with :func:`search` to | ||
restrict the match at the beginning of the string:: | ||
|
Uh oh!
There was an error while loading. Please reload this page.