グループ番号1の結果を取得できるかどうかはわかりませんが、両方の結果を同じ名前のグループに表示することができます。PowerShellの例を次に示します。
$input1 = 'Purchase of $50.00 worth groceries is required'
$input2 = 'No monthly maintenance required'
$re = '(?:(?<xyz>No) monthly maintenance|Purchase of \$(?<xyz>[\d\.]+) worth groceries)'
$match = [regex]::Match($input1, $re)
$match.Groups['xyz']
$match = [regex]::Match($input2, $re)
$match.Groups['xyz']
その結果、次のようになります。
Success : True
Captures : {50.00}
Index : 13
Length : 5
Value : 50.00
Success : True
Captures : {No}
Index : 0
Length : 2
Value : No
ただし、すべての言語が名前付きグループをサポートしているわけではありません。PowerShellは.NETFrameworkで実行されるため、これはすべての.NET言語で機能します。