Interval expressions were not traditionally available in awk.
They were added as part of the POSIX standard to make awk
and egrep consistent with each other.
For a long time, a special command-line option was required to use them in
gawk. When compatibility with POSIX has become more important
to most gawk users than compatibility with old programs,
gawk was changed to enable interval expressions by default.
Eventually, BWK awk also acquired them.
For programs that wish to use a literal ‘{’ or ‘}’ in regexp constants,
it is good practice to always escape them with a backslash. Then the
regexp constants are valid and work the way you want them to, using
any version of awk.18
When ‘{’ and ‘}’ appear in regexp constants
in a way that cannot be interpreted as an interval expression
(such as /q{a}/), then they stand for themselves.
POSIX says that interval expressions containing repetition counts greater than 255 produce unspecified results.
In the manual for GNU grep, Paul Eggert notes the following:
Interval expressions may be implemented internally via repetition. For example, ‘^(a|bc){2,4}$’ might be implemented as ‘^(a|bc)(a|bc)((a|bc)(a|bc)?)?$’. A large repetition count may exhaust memory or greatly slow matching. Even small counts can cause problems if cascaded; for example, ‘grep -E ".*{10,}{10,}{10,}{10,}{10,}"’ is likely to overflow a stack. Fortunately, regular expressions like these are typically artificial, and cascaded repetitions do not conform to POSIX so cannot be used in portable programs anyway.
This same caveat applies to gawk.
Use two backslashes if you’re using a string constant with a regexp operator or function.