The real strength of regular expressions comes from multipliers. They can be used to repeatedly apply an atom - or a parenthesized sub-expression - to a target field. Multipliers have one of the following forms (n and m denote integer values in the descriptions):
- {n} Repeat the preceding atom exactly n times. We have already seen the example '[0-9]{6}' describing 6 digits at the end of a serial number.
- {n,m} Repeat the preceding atom at least n times but at most m times. For example '(ab){2,3}' will match either 'abab' or 'ababab', but not 'ab' or 'abababab' or anything else.
- {n,} Repeat the preceding atom at least n times, without upper limit. For example '(ab){2,}' will match either 'abab' or 'ababab' or 'abababab', but not 'ab'. As a special case, n can be 0, meaning "a sequence of any number of the preceding atom including the empty sequence".
- ? Shorthand for {0,1}. In other words, it makes the preceding atom optional.
- * Shorthand for {0,}. Any number of the preceding atom, including 0.
- + Shorthand for {1,}. At least one of the preceding atom.