How many do you want?

We already learned a bit about quantifiers:
a? - 0 or 1 a
a* - 0 or more a
a+ - 1 or more a

But what if we want exact numbers?
That’s why quantifiers exist

{n} - exactly n times
{n,} - at least n times
{n,m} - between n and m times (including n and m)
{,m} - at most m times

Place them after the character you want to repeat

Hint for the Task:
Remember the | operator to separate the options

Task

Match every a that's exactly repeated 3, every b that's repeated at least 2 times, and any c that's repeated 3 to 5 times

/ /
aa
b
ccccc
aaa
a
bbb
c
ccc
Regex Cheatsheet

Here you find every Regex character explained

Anchors

  • ^ - Start of a string
  • $ - End of a string
  • \b - Word boundary
  • \B - Not word boundary

Quantifiers

  • ? - Optional
  • + - 1 or more times
  • * - 0 or more times
  • {n} - Exactly n times
  • {n,} - at least n times
  • {,m} - at most m times
  • {n,m} - Between n and m times

Character Classes

  • [abc] - Character Set
  • [^abc] - Not in character set
  • [a-z] - Range of characters
  • . - Any character except newline
  • \d - Digit
  • \D - Not a digit
  • \w - Word character
  • \W - Not a word character
  • \s - Whitespace
  • \S - Not whitespace

Groups

  • (abc) - Capturing group
  • (?:abc) - Non-capturing group
  • \1 - Group Reference

Lookarounds

  • (?=abc) - Positive lookahead
  • (?!abc) - Negative lookahead
  • (?<=abc) - Positive lookbehind
  • (?<!abc) - Negative lookbehind

Flags

  • g - Global
  • i - Case-insensitive
  • m - Multiline

Other Characters

  • \[Symbol] - Use a Regex Symbol as Text
  • | - Or