Please I want to validate the skype name using regular expressions in PHP.
NOTE: It must be between 6-32 characters, start with a letter and contain only letters and numbers (no spaces or special characters).
This pattern should work for you:
[a-zA-Z][a-zA-Z0-9\.,\-_]{5,31}
This will match a leading letter, followed by any alpha-numeric combination up to a total of between 6 - 32 characters (for the entire string).
You can use this in PHP with:
if (preg_match('/^[a-z][a-z0-9\.,\-_]{5,31}$/i', $name)) {
// you have a valid name!
}
Note, in the preg_match()
, I added the i
regex option to ignore case. Also, I lead the pattern with ^
to signify that the pattern has to start at the beginning of the string and I ended with a $
to signify that the pattern has to finish at the end of the string.
This will do the job:
preg_match( '~^[a-z][a-z0-9]{5,31}$~i', $text)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With