Regular Expressions: low-caps, dots, zero spaces

后端 未结 4 919
梦毁少年i
梦毁少年i 2021-01-24 13:09

how do I write an expression which checks for lowcaps, dots, and without any white space in the string?

the code below so far was trying to check for lowcaps and dots (i

4条回答
  •  不知归路
    2021-01-24 13:32

    I think you want this:

    if ( preg_match( '/[^a-z0-9.]/' ) ) {
        $error = true;
    }
    

    Keep in mind, I removed the !. Now if this matches, you get the error. VolkerK reversed it but forgot to remove the !, I think.

    Also, http://regexpal.com/ is your friend.

提交回复
热议问题