PHP regular expression matches a combination of 6 to 16 characters (and can only contain digits, letters, and underscores)

Source: Internet
Author: User
Tags php regular expression
PHP regular expression matches a combination of 6 to 16 characters (and can only contain digits, letters, and underscores)
This article describes how to use php regular expressions to match a combination of 6-bit and 16-bit characters. this regular expression must only contain numbers, letters, and underscores. For more information, see.

Requirement: php regular expression matches a string of 6 to 16 bits. Only 6 to 16 characters including digits, letters, and underscores are allowed. True is returned. otherwise, false is returned.

Answer: 6 to 16 digits. the regular expression can be written as follows: {6, 16 }. The regular expression of any 6 to 16 characters is as follows :. {6, 16} only allows combinations of numbers, letters, and underscores. the regular expression is [0-9_a-zA-Z]. The Complete regular expression is:

^ [_ 0-9a-z] {6, 16} $

The following is an example of applying this regular expression to verify the password.

     '; $ Password = 'abcdeasdas _ 000000'; if (ispassword ($ password) {echo' conforms to ';} else {echo' does not match ';} // output conformity?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.