Javascript regex - no white space at beginning + allow space in the middle

后端 未结 8 1719
故里飘歌
故里飘歌 2020-12-16 15:15

I would like to have a regex which matches the string with NO whitespace(s) at the beginning. But the string containing whitespace(s) in the middle CAN match. So far i have

8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 15:53

    If your field for user name only accept letters and middle of space but not for begining and end

    User name: /^[^\s][a-zA-Z\s]+[^\s]$/

    If your field for user ID only accept letters,numbers and underscore and no spaces allow

    user ID: /^[\w]+$/

    If your field for password only accept letters,number and special character no spaces allow

    Password: /^[\w@#&]+$/

    Note: \w content a-zA-Z, number, underscore (_) if you add more character, add you special character after \w.

    You can compare with user ID and password field in password field im only add some special character (@#&).

    India public thoko like

提交回复
热议问题