Reputation: 3
I am new to TPerlRegEx. Have a problem to match data from the data block due to some data have additional line is created randomly by the system.
Data
Opt:
<NVR IP: 192.168.2.163>
<SRC IP: 192.168.2.123>
<TYPE: 5>
<INPUT: 2>
<Alarm ID:66
Time: 29/07/2010 12:18:12 PM
State: 1
Assigned User: 0
Assigned Time: 01/01/1970 8:00:00 AM
Ack Time: 01/01/1970 8:00:00 AM>
<Alarm ID:67
Time: 29/07/2010 3:11:07 PM
State: 1
Assigned User: 0
Assigned Time: 01/01/1970 8:00:00 AM
Ack Time: 01/01/1970 8:00:00 AM>
<Alarm ID:68
Time: 29/07/2010 3:11:08 PM
State: 1
Assigned User: 0
Assigned Time: 01/01/1970 8:00:00 AM
Ack Time: 01/01/1970 8:00:00 AM>
Alarms got successfully
Here is my regular expression which can only match alarm 67 and 68. Alarm 66 has a additional line below and this line is randomly appear within the data block.
<Alarm\x20ID:.*?\r\n\t.*?\r\n\t.*?\r\n\t.*?\r\n\t.*?\r\n\t.*?>
Upvotes: 0
Views: 315
Reputation: 162
<Alarm\x20ID:.*?\r+\n+\t*.*?\r+\n+\t*.*?\r+\n+\t*.*?\r+\n+\t*.*?\r+\n+\t*.*?>
or perhaps better
<Alarm\x20ID:.*?(\r\n)+\t*.*?(\r\n)+\t*.*?(\r\n)+\t*.*?(\r\n)+\t*.*?(\r\n)+\t*.*?>
Upvotes: 3