We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9a73792 commit b61f411Copy full SHA for b61f411
0006-Regular-Expressions-FindIter/regex_finditer.py
@@ -0,0 +1,19 @@
1
+"""
2
+This program demonstrates the use of the re.finditer function in Python for regular expressions.
3
+It checks for all matches in the string.
4
5
+# regex_finditer.py
6
+
7
+import re
8
9
+PATTERN = r'\d+'
10
11
+# String to search
12
+TEXT = "I have 5 baskets and 10 lemons."
13
14
+# Using finditer() to find all occurrences
15
+MATCHES = re.finditer(PATTERN, TEXT)
16
17
+# Loop through the matches and print details
18
+for match in MATCHES:
19
+ print(f"Found the number {match.group()} at position {match.start()} to {match.end()}")
0 commit comments