## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

### 7.7. Matching a specific number of occurrences with \{ \}

Using the * allows us to match any number of matches, but if we want to match only a certain number of occurrences, that’s where \{ \} comes in. There are actually three options in using this pattern match, which are:

 pattern \{n\} Match n occurrences of the pattern pattern \{n,\} Match at least n occurrences of the pattern pattern \{n,m\} Match occurrences of the pattern between n and m, where n and m are integer numbers between 0 and 255

Looking at the first examples, suppose we wanted to match only three occurrences of the letter AA, but ending in the letter B, this would do it:

A\{2\}B

This would give me AAB in a match.

If we wanted to match at least four occurrences of the letter ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required