-8
^[a-zA-Z]\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,4}$

i had tried this regex for email but it allow following cases

  1. 123@mail.com
  2. example.mail@mail.com
Anonymous
  • 37
  • 1
  • 8
  • 1
    Possible duplicate of [How to validate an email address in JavaScript?](https://stackoverflow.com/questions/46155/how-to-validate-an-email-address-in-javascript) – sauerburger Mar 16 '18 at 09:10
  • That regular expression is terrible. Why would you exclude so many types of valid email addresses (e.g. subdomains, second level domains, many non-country domains, names with a period, hyphen or many other valid characters, ...)? And why would you make it even worse by not allowing leading numbers? – str Mar 16 '18 at 09:20

1 Answers1

1

Here is the code which searches for the number at the start. If number is matched it prints message in console.

let regex = /^[0-9]/;



let object = [{email:'123@mail.com'},{email:'example.mail@mail.com'}];

for(let i =0;i<object.length;i++){
  if(object[i].email.match(regex)){
    console.log('E-mail  ',object[i].email,' is not valid.')
  }
}

This is the used regex: ^[0-9]

AESTHETICS
  • 989
  • 2
  • 14
  • 32