Matches

X, exactly n times

Explanation - Capturing Groups and Character Classes with Quantifiers

Quantifiers can only attach to one character at a time, so the regular expression "abc+" would mean "a, followed by b, followed by c one or more times". It would not mean "abc" one or more times. However, quantifiers can also attach to Character Classes and Capturing Groups, such as [abc]+ (a or b or c, one or more times) or (abc)+ (the group "abc", one or more times).

Let's illustrate by specifing the group (dog), three times in a row.

Current REGEX is: (dog){3}
Current INPUT is: dogdogdogdogdogdog
Finds the text "dogdogdog" starting at index 0 and ending at index 9.
Finds the text "dogdogdog" starting at index 9 and ending at index 18.

Current REGEX is: dog{3}
Current INPUT is: dogdogdogdogdogdog
No match found.
Here the first example finds three matches, since the quantifier applies to the entire capturing group. Remove the parenthesis, however, and the match fails because the quantifier {3} now applies only to the letter "g".

Similarly, we can apply a quantifier to an entire character class:

Current REGEX is: [abc]{3}
Current INPUT is: abccabaaaccbbbc
Finds the text "abc" starting at index 0 and ending at index 3.
Finds the text "cab" starting at index 3 and ending at index 6.
Finds the text "aaa" starting at index 6 and ending at index 9.
Finds the text "ccb" starting at index 9 and ending at index 12.
Finds the text "bbc" starting at index 12 and ending at index 15.

Current REGEX is: abc{3}
Current INPUT is: abccabaaaccbbbc
No match found.
Here the quantifier {3} applies to the entire character class in the first example, but only to the letter "c" in the second.