0

i am using below regex with group name in rad software regular expression which is working fine individually but when i combine them - grouping misbehaves

regex1 - Throughput\s*\|(?<T1>[\d\.]+(?:\s+\w+)) reg1

regex2 - Connection rate\s*\|(?<T2>\s*[\d\.]+(?=\s*\|)) enter image description here

individual both are giving one match with1 group name

when i combine them like below

(Throughput\s*\|(?<T1>[\d\.]+(?:\s+\w+)))|(Connection rate\s*\|(?<T2>\s*[\d\.]+(?=\s*\|)))

which is giving 2 match 1st match T2 group not found 2nd match T1 group not found

but why in 1st match its testing T2 group not sure

enter image description here Below is my string

i am using below regex with group name in rad software which is working fine individually but when i combine them - grouping misbehaves

reg1 - Throughput\s*\|(?<T1>[\d\.]+(?:\s+\w+))
regex2 - Connection rate\s*\|(?<T2>\s*[\d\.]+(?=\s*\|))

individual both are giving one match with1 group name

when i combine them like below
(Throughput\s*\|(?<T1>[\d\.]+(?:\s+\w+)))|(Connection rate\s*\|(?<T2>\s*[\d\.]+(?=\s*\|)))

**which is giving 2 match** 
1st match T2 group not found
2nd match T1 group not found

but why in 1st match its testing T2 group not sure

Below is my string

[H[JSun Feb 19 15:08:35 IST 2023                                                                                                                                                               
Aggregated statistics (IPv4 Only) of SGMs: chassis_active VSs: 0                                                                                                                           
+--------------------------------------------------------------+                                                                                                                           
|Performance Summary                                           |                                                                                                                           
+----------------------------------------------+---------------+                                                                                                                           
|Name                                          |Value          |                                                                                                                           
+----------------------------------------------+---------------+                                                                                                                           
|Throughput                                    |34.0 K         |                                                                                                                           
|Packet rate                                   |66             |                                                                                                                           
|Connection rate                               |0              |                                                                                                                           
|Concurrent connections                        |34             |                                                                                                                           
|Load average                                  |12%            |                                                                                                                           
|Acceleration load (avg/min/max)               |2%/2%/2%       |                                                                                                                           
|Instances load (avg/min/max)                  |14%/14%/16%    |                                                                                                                           
|Memory usage                                  |17%            |                                                                                                                           
+----------------------------------------------+---------------+                                                                                                                           
 * Instances / Acceleration Cores: 4 / 2                                                                                                                                                   
 * Activated SWB: FW                                                                                                                                                                       
+------------------------------------------------------------------------------+                                                                                                           
|Per Path Distribution Summary                                                 |                                                                                                           
+------------------+--------------+--------------+--------------+--------------+                                                                                                           
|                  |Acceleration  |Medium        |Firewall      |Dropped       |                                                                                                           
+------------------+--------------+--------------+--------------+--------------+                                                                                                           
|Throughput        |0             |0             |34.0 K        |0             |                                                                                                           
|Packet rate       |0             |0             |66 K            |0             |                                                                                                           
|Connection rate   |0             |0             |0             |              |                                                                                                           
|Concurrent conn.  |0             |0             |34            |              |                                                                                                           
+------------------+--------------+--------------+--------------+--------------+                                                                                                           
                                                                                                                                                                                           
Kumaresan Sd
  • 1,399
  • 4
  • 16
  • 34
  • That is because you are using an alternation `|` with 2 groups on the left side and 2 groups on the right side. So you either match Group 1 and Group T1 OR Group 3 and Group T2. What do you want to achieve? – The fourth bird Feb 26 '23 at 09:18

0 Answers0