Python regular quantifiers

Source: Internet
Author: User

In a regular expression, you can use quantifiers to limit the number of times the previous word repeats, as shown below:


In [11]: regexp = r "j \ w {3, 6 }"


But why is there no result in the following program?


In [9]: import reIn [10]: s = "www.jeapedu.com" * 4In [11]: regexp = r "j \ w {3, 6}" In [12]: patObj = re. compile (regexp) In [13]: ret = patObj. findall (s)

After suffering, I finally found that there could not be spaces on the front of the six sides. I usually use space for programming. Why don't I have a book to remind me?


After correction, remove the space behind the comma to get the result.



(There is no problem in windows. There are spaces. In Linux, there must be no space. Otherwise, it is wrong. Have you ever encountered this problem? Haha !)


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.