Node.js: Regular Expression To Get “From: ” and “To: ”

后端 未结 2 1699
被撕碎了的回忆
被撕碎了的回忆 2021-02-14 08:11

Given this text file:

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 E         


        
2条回答
  •  無奈伤痛
    2021-02-14 08:45

    Try this:

    Code:

    //var rePattern = new RegExp(/^Received:(.*)$/);
    var rePattern = new RegExp(/^Subject:(.*)$/);
    
    var arrMatches = strText.match(rePattern);
    

    Result:

    arrMatches[0] -> Subject: test
    arrMatches[1] -> test
    

提交回复
热议问题