don*_*ald 9 javascript regex node.js
鉴于此文本文件:
Received: from unknown (HELO aws-bacon-delivery-svc-iad-1007.vdc.g.com) ([10.146.157.151])
by na-mm-outgoing-6102-bacon.iad6.g.com with ESMTP; 12 Apr 2011 14:30:47 +0000
Return-Path: 0000012f4a2a0037-528dbafb-e773-44be-bef5-07d8f63e6aee-000000@email-bounces.g.com
Date: Tue, 12 Apr 2011 14:42:37 +0000
From: xxx@xxx.example.com
To: yyy@yyy.example.com
Message-ID: <0000012f4a2a0037-528dbafb-e773-44be-bef5-07d8f63e6aee-000000@email.g.com>
Subject: test
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
X-AWS-Outgoing: 199.255.192.79
testing123
Run Code Online (Sandbox Code Playgroud)
我想获得每个领域(Return-path,Date,From,To等)以及body("testing123").
我尝试过匹配使用:
var bodyRegex = /[\n]Subject: (.+)[\n](.+)/
Run Code Online (Sandbox Code Playgroud)
但我得到空值.
Dmi*_*bev 20
试试这个:
码:
//var rePattern = new RegExp(/^Received:(.*)$/);
var rePattern = new RegExp(/^Subject:(.*)$/);
var arrMatches = strText.match(rePattern);
Run Code Online (Sandbox Code Playgroud)
结果:
arrMatches[0] -> Subject: test
arrMatches[1] -> test
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
39178 次 |
| 最近记录: |