Commit 0e21c25
committed
feat: Enhance email validation and Gmail domain detection in Email2 class
- Prompted user to enter an email address via Scanner.
- Improved email validation by checking both presence of '@' and that '.' appears after '@'.
- Extracted:
- Username (substring before '@')
- Domain name (substring after '@')
- Displayed extracted username and domain.
- Checked whether the domain:
- Starts with "gmail" (case-insensitive)
- Is exactly "gmail.com" (case-insensitive), by parsing substring before first '.'
- Handled cases where domain is malformed (i.e., no '.' after '@').
- Closed Scanner to prevent resource leak.
This update improves robustness in email parsing and provides accurate checks for Gmail domains.
Signed-off-by: Somesh diwan <[email protected]>1 parent 8d8e1a9 commit 0e21c25
1 file changed
+1
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
| 39 | + | |
0 commit comments