Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How do php regular expressions get the text with a specified length?
How do php regular expressions get the text with a specified length?
If you only limit the length of the user name or password, there is no need to use regularization.

$ user = $ _ POST[' user '];

if(strlen($ user)& lt; 6 || strlen( $user)> 12 ) {

The length of user name can only be 6- 12 digits.

}

If you want to limit the length and it can only be alphanumeric, then you can use regularization.

If (! preg_match('/^\w{6, 12}$/is'){

User name must be a combination of alphanumeric underscore and 6- 12 digits.

}

As for your second question, it is estimated that there is no uniform code, otherwise it is impossible to have that kind of personality.