Skip to content

Commit a574882

Browse files
committed
feat: Extract and validate email components (username and domain)
🎯 Purpose: Implements email string parsing to separate and validate username and domain components of an email address, with specific validation for Gmail domains. 🧠 Logic: 1. Email Parsing: - Locates '@' symbol using indexOf() to split email components - Extracts username portion before '@' using substring(0, indexOf('@')) - Extracts domain portion after '@' using substring(indexOf('@') + 1) 2. Domain Validation: - Performs Gmail-specific domain validation using two approaches: a) startsWith("Gmail") to check domain beginning b) equalsIgnoreCase("gmail") for case-insensitive exact match - Extracts domain name before '.com' for precise validation 🔍 Technical Details: - Uses String methods: indexOf(), substring(), startsWith(), equalsIgnoreCase() - Handles email format: "[email protected]" - Implements case-insensitive domain validation - Separates domain validation logic from extraction logic 📋 Example: Input: "[email protected]" Output: - Username: "Programmer" - Domain: "Gmail.com" - Gmail Validation: true 💡 Note: This implementation focuses on basic email component extraction and Gmail domain validation. For production use, consider adding additional validation rules and error handling for malformed email addresses. Signed-off-by: Somesh diwan <[email protected]>
1 parent 0f45150 commit a574882

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

Section9ArrayAB/Array 2.0/src/StudentChallengeAB.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
public class StudentChallengeAB {
22
public static void main(String[] args) {
33
String str = "[email protected]";
4-
54
int i = str.indexOf("@");
65
String uname = str.substring(0 , i);
76
String domainname = str.substring(i+1, str.length());

0 commit comments

Comments
 (0)