You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This script demonstrates the use of Python's `re.findall()` function to find all words in a given text that start with the letter "I".
4
+
5
+
## Description
6
+
The script imports the `re` module (Python's regular expressions module) and uses `re.findall()` with the pattern `\bI\w+` to find all words that begin with the capital letter "I".
7
+
8
+
-`\b` asserts a word boundary, ensuring we only match words starting with "I".
9
+
-`I` matches the literal capital letter "I".
10
+
-`\w+` matches one or more word characters following "I".
11
+
12
+
The script runs two examples to demonstrate the regex:
13
+
14
+
1. Text: "The rain is happening in India"
15
+
- Expected output: `["India"]`
16
+
17
+
2. Text: "The rain is happening in India and Ireland"
18
+
- Expected output: `["India", "Ireland"]`
19
+
20
+
## Usage
21
+
To run the script, you need Python 3 installed on your system. You can execute it using the following command:
0 commit comments