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

Fix suggestion for 03-regex-findall.py, thanks for consideration. #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix suggestion for 03-regex-findall.py, thanks for consideration.
The code is using re.search instead of re.findall, therefore is only returning one entry even if there are multiple in the input text.
madhoshyagnik authored Jul 27, 2024
commit fa64687753ea6b6c163ed7b7882d908bfb8fc0e3
8 changes: 4 additions & 4 deletions Day-02/examples/03-regex-findall.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import re

text = "The quick brown fox"
text = "The quick brown brown brown fox"
pattern = r"brown"

search = re.search(pattern, text)
if search:
print("Pattern found:", search.group())
findall = re.findall(pattern, text)
if findall:
print("Pattern found:", findall)
else:
print("Pattern not found")