Skip to content

Match between n and m times -- the example doesn't match the description of the example #19078

Open

Description

"In the following example, the regular expression (00\s){2,4} tries to match between two and four occurrences of two zero digits followed by a space. Note that the final portion of the input string includes this pattern five times rather than the maximum of four. However, only the initial portion of this substring (up to the space and the fifth pair of zeros) matches the regular expression pattern."
In the code snippet, the final portion of the input string indeed does NOT include the pattern five times rather than the maximum of four, because the closing quote that finishes defining the pattern does not have the final ' ' space or whitespace character before it and after the last two 0 characters. If it is added in or restored, then the code example provided would match the description exactly.
As it is, I find it confusing because it is meant to illustrate the semantics of the {m,n} construct, and the reason that it only matches four is ambiguous to someone who doesn't already clearly understand why. If the final part of the string were to become 00 00 00 00 00 00 -- the output would remain the same but I think the example would be more clearly illustrative. We are only getting four of them because that is the upper limit of that requested -- not because the pattern can only be matched at most four times as the example stands.
[Enter feedback here]


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions