How to make both matches belong to group 1?
regex:
^.{7}(.*).{4}|(.*).{4}
values:
QOQSNT.ini
QOQSNT_MSSQLSERVER.ini
Result:
Red is Group 1
Green is Group 2
How to make both matches belong to group 1?
regex:
^.{7}(.*).{4}|(.*).{4}
values:
QOQSNT.ini
QOQSNT_MSSQLSERVER.ini
Result:
Red is Group 1
Green is Group 2
In PCRE and Boost, you can use a branch reset group:
(?|^.{7}(.*).{4}|(.*).{4})
^^^ ^ ^
See the regex demo.
However, you may also use
([^_]+)\.[^.]+$
See the regex demo.
Details
([^_]+) - Group 1: any one or more chars other than _\. - a dot[^.]+ - 1+ chars other than a dot$ - end of string.