Because {n}+
doesn't mean what you think it does. In PCRE syntax, this turns {n}
into a possessive quantifier. In other words, a{5}+
is the same as (?>a{5})
. It's like the second +
in the expression a++
, which is the same as using an atomic group (?>a+)
.
This has no use with a fixed-length {n}
but is more meaningful when used with {min,max}
. So, a{2,5}+
is equivalent to (?>a{2,5})
.
As a simple example, consider these patterns:
^(a{1,2})(ab) will match aab -> $1 is "a", $2 is "ab"
^(a{1,2}+)(ab) won't match aab -> $1 consumes "aa" possessively and $2 can't match