Skip to content
Regex

Quantifiers

Control how many times a token repeats.

By EZ4Code Team
quantifiergreedylazy

Code

a*        zero or more
a+        one or more
a?        zero or one
a{3}      exactly 3
a{3,}     3 or more
a{3,5}    between 3 and 5
a*?       lazy (fewest) version of *
a+?       lazy one or more
colou?r   matches color or colour

Explanation

Quantifiers specify how many repetitions of the preceding token to match, from fixed {3} to bounded {3,5} ranges. By default they are greedy and match as much as possible; appending a question mark makes them lazy so they match the fewest characters. colou?r shows how ? makes a letter optional.

More Regex Snippets