如何匹配以 MTA: 开头的整行?
如果我使用:
console.log(result[2].split("Reporting-MTA:"))
我仍然会得到该行的其余部分,我想匹配以 MTA 开头的整行:
谢谢
编辑:
我想匹配该行,以便我可以阅读整行之前和之后的行。现在,我只能读取字符串“Reporting-MTA:”前后的行
编辑2:
2u+in.4eBZWuGLW.HROP9.bB7WHG
content-type: message/delivery-status
Reporting-MTA: dns; na-mm-outgoing-6102-bacon.iad6.com
Final-Recipient: rfc822;g
Action: failed
Status: 5.0.0 (permanent failure)
Diagnostic-Code: smtp; 5.1.2 - Bad destination host 'DNS Hard Error looking up tiagop.fdforg (MX): NXDomain' (delivery attempts: 0)
/node/server.js:92
console.log(r[1]);
^
TypeError: Cannot read property '1' of null
使用这段代码:
console.log(result[2]);
var r = result[2].match(/(.*)\r\nReporting-MTA\r\n(.*)/)
console.log(r[1]);
最佳答案
关于javascript - Node.js:删除整行的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5674694/