Reputation: 69
`## (Chat room 1) Received connection request from client 1.
(CR 1) RR 1.
(CR 1) AC 1.
(CR 0) RC 2.
The Image above clearly depict my problem. I am trying to match RR,AC and RC . I do not want a broad match but a specific match for either RR or AC or RC below is my attempted regex that works but its a broad match so long has one of these letters are found
(##[^\n]*\n)|(\(CR (\d+))\) [AC\RR\RC\] [0-9]+.
Additionally i tried using quotation enclosing each pair letter like this below;
(##[^\n]*\n)|(\(CR (\d+))\) ["AC"\"RR"\"RC"\] [0-9]+.
It is still a broad match
Upvotes: 0
Views: 223
Reputation: 13
\)\s(.{2})\s
As pattern is similar have taken the ) space and group with range of 2 and end with space again .
Upvotes: 0
Reputation: 163207
You could match the leading ## followed by the rest of the line and use a single capturing group to match one of the 3 alternatives:
^##.*\n\(CR \d+\) (R[RC]|AC) \d+\.
Explanation
^
Start of string##.*\n
Match ##
, the rest of the line and a newline\(CR \d+\)
Match (CR
and space, 1+ digits and )
(
Capture group 1
R[RC]|AC
Match RR
or RC
or AC
)
Close group 1 \d+.
Match a space, 1+ digits and a dotUpvotes: 1