Thursday, 21 July 2016

Validate username as alphanumeric with underscores using PHP

Regular Expression is /^[A-Za-z0-9_]+$/
This allows just alphanumeric characters and the underscore.

Eg:
      if( preg_match('/^[A-Za-z0-9_]+$/', 'hello123_') )
             echo "Success";
      else
             echo "Fail";

No comments:

Post a Comment

Git merge branch to another branch

$ git checkout develop $ git pull $ git checkout test-branch $ git merge develop $ git push