Valid Email Address

Write a bash script that finds all the invalid email addresses.

For simplicity, assume that a vaild email addresses has the following rules-

  • Email should be of the form local@domain.com
  • There can only be alphanumberic characters in the local part email address.
  • The following characters are valid in the local part of the email as long as they are not the first character.
    -, _, +, .

  • Email address can not start with a number.
  • Domain name can only contain alphanumeric characters and -.
  • com part can have atmost one ., for e.g. co.uk or co.in is valid but as.df.gh is invalid

Example:

Assume that input has the following content:

abc@example.co.uk
abc@example.com
abc<>@example.com
abc@example@gmail.com

Your script should output the following:

abc<>@example.com
abc@example@gmail.com
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Valid Email Address on Interview Code Editor
Sign Up
to access hints and editorial solutions for Valid Email Address

Discussion


Loading...
Click here to start solving coding interview questions