I'm new to pegexp and I want to write a short one which validates emails. Here is my regexp:
^[a-zA-Z0-9_.-]+@[_a-zA-Z0-9-]+\.[_a-zA-Z0-9-.]+$
The valid email consists of part1@part2. Where part1 consists of 1 or more words, divided by '.' and part2 consists of 2 or more words, divided by '.' Each word consists of a-z or A-Z or 0-9 or - or _
These emails are NOT correct:
smth...smth@smth.smth...
...@a...
I don't know how to fix my regexp and exclude theese examples.