私は次のように私の入力を持っています、
入力
StatusMsg:
seqId: 14043
timestamp: 140707
dId: "Sa01"
msgType: SEQUENCE
eventType: UPDATE_CMD
devContext {
context: IDLE
operationalMode: 1
logHistory {
start: 1404387563607
end: 1404387563616
}
}
manifest {
timestamp: 1404387733059
dev {
dId: "Sa01"
mainComponent {
serialNum: "10001"
deviceClass: "Sap"
componentType: "Sa01"
subcomponentNum: 1
}
}
info {
name: "Sa01"
channels: 1
lib {
name: "l.bin"
timestamp: 1404387733059
version: "6870711ee"
validStartDate: 1404387733059
}
activeSW {
name: "Sa01"
timestamp: 1404387733059
version: "12.001"
validStartDate: 1404387733059
}
activeCSW {
name: "Sa01"
timestamp: 1404387733059
version: "03.001"
validStartDate: 1404387733059
}
}
}
powerStatus {
powerEvent: ON
powerSource: AC
chargerStatus: CHARGING
batteryStatus: GOOD
}
status {
msgHeader {
messageId: 13
timestamp: 1404387733059
seqNum: 13
sourceId: 13
numOfParams: 0
}
infuserState: READY
keypadLockout: UNLOCKED
}
cmdResponse {
cmdType: A_PGM
aPgm {
dId: "Sa01"
refId: 79
request {
refId: 79
libId: "6870711eedb"
channelId: 1
lId: 1
pgmType: FULL
aPgmType: NEW
externalId: "EXT_ID_9"
stats {
WG: 76230
HG: 150500
BS: 1790
}
multi: false
}
response {
dId: "Sa01"
files: 1.bin
major: 338013710701
status: Received
}
}
}
[2014-07-07 14:10:41.034] I/O Received
StatusMsg:
seqId: 14043
timestamp: 140707
dId: "Sa01"
msgType: SEQUENCE
eventType: UPDATE_CMD
devContext {
context: IDLE
operationalMode: 1
logHistory {
start: 1404387563607
end: 1404387563616
}
}
manifest {
timestamp: 1404387733059
dev {
dId: "Sa01"
mainComponent {
serialNum: "10001"
deviceClass: "Sap"
componentType: "Sa01"
subcomponentNum: 1
}
}
info {
name: "Sa01"
channels: 1
lib {
name: "l.bin"
timestamp: 1404387733059
version: "6870711ee"
validStartDate: 1404387733059
}
activeSW {
name: "Sa01"
timestamp: 1404387733059
version: "12.001"
validStartDate: 1404387733059
}
activeCSW {
name: "Sa01"
timestamp: 1404387733059
version: "03.001"
validStartDate: 1404387733059
}
}
}
powerStatus {
powerEvent: ON
powerSource: AC
chargerStatus: CHARGING
batteryStatus: GOOD
}
status {
msgHeader {
messageId: 13
timestamp: 1404387733059
seqNum: 13
sourceId: 13
numOfParams: 0
}
infuserState: READY
keypadLockout: UNLOCKED
}
cmdResponse {
cmdType: A_PGM
aPgm {
dId: "Sa01"
refId: 79
request {
refId: 79
libId: "6870711eedb"
channelId: 1
lId: 1
pgmType: FULL
aPgmType: NEW
externalId: "EXT_ID_9"
stats {
WG: 76230
HG: 150500
BS: 1790
}
multi: false
}
response {
dId: "Sa01"
files: 1.bin
major: 35723057325
status: Valid
}
}
}
[2014-07-07 14:15:71.028] I/O Received
StatusMsg:
seqId: 14043
timestamp: 140707
dId: "Sa01"
msgType: SEQUENCE
eventType: UPDATE_CMD
devContext {
context: IDLE
operationalMode: 1
logHistory {
start: 1404387563607
end: 1404387563616
}
}
manifest {
timestamp: 1404387733059
dev {
dId: "Sa01"
mainComponent {
serialNum: "10001"
deviceClass: "Sap"
componentType: "Sa01"
subcomponentNum: 1
}
}
info {
name: "Sa01"
channels: 1
lib {
name: "l.bin"
timestamp: 1404387733059
version: "6870711ee"
validStartDate: 1404387733059
}
activeSW {
name: "Sa01"
timestamp: 1404387733059
version: "12.001"
validStartDate: 1404387733059
}
activeCSW {
name: "Sa01"
timestamp: 1404387733059
version: "03.001"
validStartDate: 1404387733059
}
}
}
powerStatus {
powerEvent: ON
powerSource: AC
chargerStatus: CHARGING
batteryStatus: GOOD
}
status {
msgHeader {
messageId: 13
timestamp: 1404387733059
seqNum: 13
sourceId: 13
numOfParams: 0
}
infuserState: READY
keypadLockout: UNLOCKED
}
cmdResponse {
cmdType: A_PGM
aPgm {
dId: "Sa01"
refId: 79
request {
refId: 79
libId: "6870711eedb"
channelId: 1
lId: 1
pgmType: FULL
aPgmType: NEW
externalId: "EXT_ID_9"
stats {
WG: 76230
HG: 150500
BS: 1790
}
multi: false
}
response {
dId: "Sa01"
files: 1.bin
major: 27151510570
status: Accepted
}
}
}
[2014-07-07 14:15:51.034] I/O Received
StatusMsg:
seqId: 14043
timestamp: 140707
dId: "Sa01"
msgType: SEQUENCE
eventType: UPDATE_CMD
devContext {
context: IDLE
operationalMode: 1
logHistory {
start: 1404387563607
end: 1404387563616
}
}
manifest {
timestamp: 1404387733059
dev {
dId: "Sa01"
mainComponent {
serialNum: "10001"
deviceClass: "Sap"
componentType: "Sa01"
subcomponentNum: 1
}
}
info {
name: "Sa01"
channels: 1
lib {
name: "l.bin"
timestamp: 1404387733059
version: "6870711ee"
validStartDate: 1404387733059
}
activeSW {
name: "Sa01"
timestamp: 1404387733059
version: "12.001"
validStartDate: 1404387733059
}
activeCSW {
name: "Sa01"
timestamp: 1404387733059
version: "03.001"
validStartDate: 1404387733059
}
}
}
powerStatus {
powerEvent: ON
powerSource: AC
chargerStatus: CHARGING
batteryStatus: GOOD
}
status {
msgHeader {
messageId: 13
timestamp: 1404387733059
seqNum: 13
sourceId: 13
numOfParams: 0
}
infuserState: READY
keypadLockout: UNLOCKED
}
cmdResponse {
cmdType: A_PGM
aPgm {
dId: "Sa01"
refId: 79
request {
refId: 79
libId: "6870711eedb"
channelId: 1
lId: 1
pgmType: FULL
aPgmType: NEW
externalId: "EXT_ID_9"
stats {
WG: 76230
HG: 150500
BS: 1790
}
multi: false
}
response {
dId: "Sa01"
files: 1.bin
major: 35723057325
status: Valid
}
}
}
以下が同じ順序で入力に存在することが必須であることを確認したいのですが、
StatusMsg:
dId: "Sa01"
eventType: UPDATE_CMD
cmdResponse
cmdType: A_PGM
response
dId: "Sa01"
status: Accepted
期待される出力
StatusMsg:
seqId: 14043
timestamp: 140707
dId: "Sa01"
msgType: SEQUENCE
eventType: UPDATE_CMD
devContext {
context: IDLE
operationalMode: 1
logHistory {
start: 1404387563607
end: 1404387563616
}
}
manifest {
timestamp: 1404387733059
dev {
dId: "Sa01"
mainComponent {
serialNum: "10001"
deviceClass: "Sap"
componentType: "Sa01"
subcomponentNum: 1
}
}
info {
name: "Sa01"
channels: 1
lib {
name: "l.bin"
timestamp: 1404387733059
version: "6870711ee"
validStartDate: 1404387733059
}
activeSW {
name: "Sa01"
timestamp: 1404387733059
version: "12.001"
validStartDate: 1404387733059
}
activeCSW {
name: "Sa01"
timestamp: 1404387733059
version: "03.001"
validStartDate: 1404387733059
}
}
}
powerStatus {
powerEvent: ON
powerSource: AC
chargerStatus: CHARGING
batteryStatus: GOOD
}
status {
msgHeader {
messageId: 13
timestamp: 1404387733059
seqNum: 13
sourceId: 13
numOfParams: 0
}
infuserState: READY
keypadLockout: UNLOCKED
}
cmdResponse {
cmdType: A_PGM
aPgm {
dId: "Sa01"
refId: 79
request {
refId: 79
libId: "6870711eedb"
channelId: 1
lId: 1
pgmType: FULL
aPgmType: NEW
externalId: "EXT_ID_9"
stats {
WG: 76230
HG: 150500
BS: 1790
}
multi: false
}
response {
dId: "Sa01"
files: 1.bin
major: 27151510570
status: Accepted
}
}
}
正規表現でやってみましたが、
(StatusMsg:.*?dId:\s*"Sa01".*?eventType: UPDATE_CMD.*?response\s*{[\s\n\w\.:]*dId:\s*"Sa01"[\s\n\w\.:]*status:\s*Accepted)
上記の式は、最初のStatusMsgからAcceptedまでを選択します。正しい正規表現のフレーミングを手伝ってくれる人はいますか?