Regex Repetition Qualifiers, Anchors, and Grouping

Learn about the different functionalities of using regular expressions.

Regex repetition qualifiers

It’s possible to repeat either a portion or a full regex pattern. The metacharacters to do so are *, +, ?, and {}:

  • *: It specifies that the character previous to it can be repeated zero or more times.
  • +: It specifies that the character previous to it can be repeated one or more times.
  • ?: It specifies that the character previous to it can be repeated zero or one time.
  • {m}: It specifies that exactly m copies of the previous regular expression should be matched.
  • {m,n}: It causes the resulting regular expression to match from m to n repetitions of the preceding regular expression.

Get hands-on with 1400+ tech skills courses.