Site Tools


Hotfix release available: 2025-05-14b "Librarian". upgrade now! [56.2] (what's this?)
Hotfix release available: 2025-05-14a "Librarian". upgrade now! [56.1] (what's this?)
New release available: 2025-05-14 "Librarian". upgrade now! [56] (what's this?)
prog:php:functions:regex

# e-mail check:

$regex = '^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]{1,})*\.([a-z]{2,}){1}$';
$email = "rene18@neti.ee";
  if (eregi($regex, $email)) {
   echo $email . ' matched<br>';
  } else {
   echo $email . ' not matched<br>';
  }

# card number check: first 10 chars have to be numbers and the eleventh is either a number or an “x”

$card_number = "1234567890X";

$regex = '^[0-9]{10}[0-9Xx]{1}$';

if (eregi('^[0-9]{10}[0-9Xx]{1}$', $card_number)) {
    echo "match!\n";
} else {
    echo "fail\n";
}
prog/php/functions/regex.txt · Last modified: 2019/09/20 15:52 by 127.0.0.1