dongzhouhao4316 2012-10-13 02:07
浏览 425
已采纳

正则表达式,不含空格或特殊字符[关闭]

I am new to regular expressions and I need a regex for php username that matches

no spaces

no special characters

in length 8, max 32

and also a regex for password that matches


alphanumeric have at least one digit and one character

no spaces
  • 写回答

1条回答 默认 最新

  • douzhe2981 2012-10-13 02:13
    关注

    Try the following REGEX :

    ^\S+\w{8,32}\S{1,}
    
    • ^ means beginning of line
    • \S means all characters but not a space or a tab
    • + mean at least one character
    • \w means an alphanumeric character including _
    • {8,32} means at least 8 characters, and max 32
    • \S still means all characters but not a space or a tab
    • {1,} means at least 1 item
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?