Username regular expression in php

I'm creating a login system with PHP and I don't know how to set a regular expression for the "username" field. I created this regex but I'm not sure it works properly: /([A-Za-z0-9-_.])\w+/ Actually, I don't understand what w+ stand for...


  1. Can includes letters (a-z, A-Z) and numbers,
  2. Can includes periods (dot, I don't know how to call it but it's the symbol .)
  3. Can includes underscore
  4. Can includes minus symbol (-)
  5. No matter how username starts (in other words, no matter which is the first letter).

Can anyone help me, please?

Thanks Marc