Python Regular Expression Demo

Source: Internet
Author: User

1, match the case and the number, and the case number must have, and the string length is 6~20 bit

^ (? =.*\d) (? =.*[a-z]) (? =.*[a-z]) [a-za-z\d]{6,20}$

Import re
Pattern = Re.compile ("^ (? =.*\d) (? =.*[a-z]) (? =.*[a-z]) [a-za-z\d]{6,20}$])
Flag = Pattern.match ("abcDEF123")
If flag:
Print "String matches the pattern."
Else
Print "String doesn ' t match the pattern."

(? =.*\d): Indicates that there are numbers in the string
(? =.*[a-z]): Indicates a lowercase letter in a string
(? =.*[a-z]): Indicates that there are uppercase letters in the string
[A-za-z\d] {6,20}: Indicates that the uppercase and lowercase characters in the string and the total number of digits are 6~20
^$: Represents the beginning and end of a string, respectively


http://hlee.iteye.com/blog/327993

Python Regular Expression Demo

Related Article

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.