Skip to content

Instantly share code, notes, and snippets.

@roberto-butti
Created February 14, 2013 17:42
Show Gist options
  • Save roberto-butti/4954572 to your computer and use it in GitHub Desktop.
Save roberto-butti/4954572 to your computer and use it in GitHub Desktop.
Validazione stringa lunga da 1 a 250 caratteri, che comprende: lettere minuscole, maiuscole, numeri, spazi, punto e trattino
<?php
$username = "user-name12";
$exp = "/^[a-zA-Z\d\ \.-]{1,250}$/i";
if (preg_match($exp, $username)) {
echo "Your username is ok.";
} else {
echo "Wrong username format.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment