【发布时间】:2014-07-03 16:40:18
【问题描述】:
对以下输入使用正则表达式:
输入
response {
id: 1
files: 1.bin
major: 338013710701
status: Received
}
response {
id: 1
files: 1.bin
major: 35723057325
status: Valid
}
response {
id: 1
files: 1.bin
major: 27151510570
status: Accepted
}
我期待匹配的输出:
预期输出
response {
id: 1
files: 1.bin
major: 27151510570
status: Accepted
其中id: 1 是匹配项所必需的。我尝试使用以下正则表达式:
/response {\n {3}id: 1.*?status: Accepted/m
它从第一个 response 到 status: Accepted 进行选择。任何人都可以帮助构建正确的正则表达式以匹配预期的输出吗?
【问题讨论】: