@LAST_MATCH_END @+ ... You can use $#+ to determine how many subgroups were in the last successful match. ... @LAST_MATCH_START @- ... One can use "$#-" to find the last matched subgroup in the last successful match. Contrast with $#+, the number of subgroups in the regular expression.