<pre><?php$target = "my.e-mail_with_symbols@domain.com.br";$re = "/^([a-z0-9\._\-]*)(@{1})([a-z0-9\._\-]*)(\.[a-z0-9]{1,3})$/i";echo "<b>$re</b> \t\t\t <b>$target</b>\n\n\n";if(preg_match($re, $target, $out)) { echo "<span style=\"color: blue;\">matchs</span>";} else { echo "<span style=\"color: red;\">doesn't match</span>";}echo "\n\n\n\n";print_r($out);?></pre>
I just started trying some things with regular expressions, and I found this not to be that difficult, but i'm sure i just understand the basics.If someone who knows regexp could see if what I mean is what I wrote, I'd be very thankful!Here it goes:^ = must start with the first "block";([a-z0-9\._\-]*) = a to z, 0 to 9, with ".", "_" and "-" allowed infinite times(@{1}) = "@" must come after the first block only once([a-z0-9\._\-]*) = 3rd block, the same as the first(\.[a-z0-9]{1,3}) = last block preceeded by an dot (mandatory) having alphanumeric chars. Can find this pattern at least once and at most 3 tmes.$ = must end after the abovei = makes the pattern case insensitive.Is all this right? Am I on the right track of regexp? Am I using some unusual/bad practice with the patterns?Thanks a lot!!