Ask for a basic knowledge of a regular expression.

Source: Internet
Author: User
Do not know where this question should be asked, borrow treasure to ask for a moment.
Just see an example, there are three groups of characters as follows:
Z
Zo
Zoo
Why zo* can match Z? Zo+ can only match Zo,zoo.
is zo* equal to z{1}o*?
Beginners have just started to learn the regular, many places still do not understand, but also the master to give guidance, thank you.


Reply to discussion (solution)

* Indicates a match for the preceding character 0 or more times, + indicates one or more times
Zo* indicates that there are 0 or more o,zo+ behind Z to indicate that there are 0 or more o behind the Zo

Why zo* can match Z? Zo+ can only match Zo,zoo.
* Indicates a match 0 or more times

So zo* match Z back 0 o to n o all can
Z
Zo
Zoo
Zoooo ... All can

If you want to match at least once
Should write zo+

Thank you upstairs for two people.
* and + meaning I understand that I just don't understand the scope of their influence. According to your answer, it appears that * and + will only affect O and have no effect on Z. I have always thought that zo* means there are 0 or n zo, that seems I understand wrong, zo* should be referring to have 1 z,0 or n o, it should be so?

Thank you upstairs for two people.
* and + meaning I understand that I just don't understand the scope of their influence. According to your answer, it appears that * and + will only affect O and have no effect on Z. I have always thought that zo* means there are 0 or n zo, that seems I understand wrong, zo* should be referring to have 1 z,0 or n o, it should be so?



Well, you understand right now.

0 or n zo should be written like this (ZO) *

Why zo* can match Z?
Zo* represents a combination of a z and a 0 to n O of characters

The matching unit of a regular expression is a character, not a word

Thank you all, now it's clear.

  • 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.