PHP Regex Problem (adınızı, doğum, e-posta adresi)

0 Cevap php

The below regex's don't seem to be working. Is it because of !preg_match?
Username

if (!preg_match("/^[A-Za-z](?=[A-Za-z0-9_.]{3,31}$)[a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*$/",$_POST['username'])) {
    $hasErr = true;
    $return['username'] = 'Please enter a valid username. Use 4 to 32 characters '
                        . 'and start with a letter. You may use letters, numbers, '
                        . 'underscores, and one dot (.).';
}

Doğum

if (!preg_match("'\b(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2}\b'", $_POST['birthdate'])) {
    $hasErr = true;
    $return['birthdate'] = 'Please enter your birthdate in a valid format. mm/dd/yyy';
}

E-posta Adresi

if (!preg_match("'\b[A-Z0-9._%-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b'",$_POST['email'])) {
    $hasErr = true;
    $return['email'] = 'Please enter a valid email address.';
}

0 Cevap