android is string email

// Step 1: Define a regular expression pattern for validating an email address
val emailPattern = "[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}".toRegex()

// Step 2: Get the email string from user input or any other source
val userEmail: String = "[email protected]" // Replace with actual email input

// Step 3: Check if the email string matches the defined pattern
val isEmailValid = emailPattern.matches(userEmail)

// Step 4: Display the result based on the validation outcome
if (isEmailValid) {
    // Email is valid
    println("Valid email address.")
} else {
    // Email is invalid
    println("Invalid email address.")
}