我将试图说明我的问题:
我有一些终端输出,如下所示:

First:
从这个列表中,我希望过滤(例如) Safari中的所有进程。所以我会得到我在图片上标上蓝色的线条。
第二步:从新列表(过滤的Safari-行)开始,我希望在"->“签名之后获得ip,直到":http”为止。
因此,我使用这个正则表达式:
var regexp = /->(.*):/g;
var ip = regexp.exec(*TheBigListWithAllConnections*)[1];
console.log(ip);但是这个正则表达式只给了我第一个发现的ip。但我想要的是ips。
这将是很高兴有一些提示如何达到这个目标!
发布于 2014-06-16 12:53:17
发布于 2014-06-16 12:59:01
要获取数组中的所有IP地址,请使用以下循环:
var regexp = /->([^:]+)/g,
matches = [],
input = TheBigListWithAllConnections;
while (match = regexp.exec( input ))
matches.push( match[1] );
console.log(matches);https://stackoverflow.com/questions/24244117
复制相似问题