Validating user input in perl
We just have to make sure that when we try to validate an e-mail address first we'll convert the string to lower-case letters.
In order to verify if we have the correct regex we can write a script that will go over a bunch of string and check if Email:: Valid agrees with our regex: examples/email_
In various use-cases, but especially at web-based registration forms we need to make sure the value we received is a valid e-mail address.
Another common use-case is when we get a large text-file (a dump, or a log file) and we need to extract the list of e-mail address from that file.
This could have been avoided by implementing simple validation techniques.
The problem is that the username cannot start with a dot. We add a new character class at the beginning that will only match letter and digits.
We only need one such character, so we don't use any quantifier: because that would mean we actually require at least 2 character for every username.
I am not really sure if there are length limitation on either of the username or the domain name.
Because we will want to make sure the given string matches exactly our regex, we start with an anchor matching the beginning of the string We can use all lower-case characters as the e-mail addresses are case sensitive.