From fa64687753ea6b6c163ed7b7882d908bfb8fc0e3 Mon Sep 17 00:00:00 2001 From: Madhosh Yagnik Date: Sat, 27 Jul 2024 08:50:53 +0530 Subject: [PATCH] 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. --- Day-02/examples/03-regex-findall.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Day-02/examples/03-regex-findall.py b/Day-02/examples/03-regex-findall.py index ec5cdd5c..76fcaa1c 100644 --- a/Day-02/examples/03-regex-findall.py +++ b/Day-02/examples/03-regex-findall.py @@ -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")