The range-matching feature lets you specify the number of times that a subpattern must appear in a match. You can specify an exact number, a minimum number, or both a minimum and maximum number:
(subpattern){n[,[m]]}
In the preceding syntax, you must type the braces ({ and }).
( subpattern ){ n } specifies that subpattern must appear exactly n times. For example, the following pattern specifies that subpattern (A.B|C) must appear exactly 3 times:
'X.(Y.Z).(A.B|C){3}'
The preceding pattern is equivalent to the following pattern:
'X.(Y.Z).(A.B|C).(A.B|C).(A.B|C)'
( subpattern ){ n , } specifies that subpattern must appear at least n times. For example, the following pattern specifies that subpattern (A.B|C) must appear at least 4 times:
'X.(Y.Z).(A.B|C){4}'
The preceding pattern is equivalent to the following pattern:
'X.(Y.Z).(A.B|C).(A.B|C).(A.B|C).(A.B|C)*'
( subpattern ){ n , m } specifies that subpattern must appear at least n times and at most m times. For example, the following pattern specifies that subpattern (A.B|C) must appear at least 2 times and at most 4 times:
'X.(Y.Z).(A.B|C){2,4}'
The preceding pattern is equivalent to the following pattern:
'X.(Y.Z).(A.B|C).(A.B|C).(A.B|C)?.(A.B|C)?'