Capture groups, both named/unnamed are counted sequentially as found.
There are exceptions to this, flavors that support branch reset and Dot-Net’s
flavor, which does not support branch reset.
Inside branch resets, capture group counting resets after each alternation.
And past the branch reset, counting starts from the largest group found
inside the branch reset plus 1.
Dot-Net’s flavor doesn’t support branch resets, although it offers the ability
to turn off counting of ‘named’ capture groups.
When Dot-Net language is selected and Count named capture groups
and Named groups last are enabled, the counting is as follows:
Sequentially counts all the ‘unnamed’ groups first, then counts the ‘named’
groups last. This could cause confusion if referencing a capture group by number.
RegexFormat internally tracks capture counting order of both ‘named’ and ‘unnamed’
groups based on the Flags settings (see Flags Pane).
Under the Language Elements category is the Group Counting subsection.
Use these options to control if and how ‘named’ capture groups are counted.
The Count named capture groups option is the default setting for all presets.
The Named groups last option is disabled for all but the Dot-Net preset.
As with all languages, all options are available if Custom preset is selected
from the context menu. The custom setting just keeps what options are
currently selected and opens up all other options that were not previously
A good way to view the current counting scheme is to format with the
Formatting category, Annotations subsection enabled
(see Formatted Annotations).
Another good way is to turn on auto-generated group number comments
(see Comment Handling).
Either or both of these methods will give an accurate view of how regex
engines will see your regular expression and will help diagnose problems.
This shows a Dot-Net language configured regular expression input.
Named capture counting is enabled as is count named groups last.
Formatting annotations are enabled.
Auto-generated comments of capture group numbers are enabled
as well as having a vertical shape and uses comment shift.
Named/unnamed capture group comments have this format:
# ( grpnum ) …
If count named groups last is enabled (like here), named groups
have this format:
#_( grpnum ) …
The difference is a visual cue, an underscore.
RegexFormat Help - © 2014 RDNC Software