如何获取"="用最短的剧本?
DATEADDED=20210301 20:21:02 identity =* IP=88.164.x。x REASON=aaa bbb ccc…
将所有内容放入数组
的例子:
Result response of array:['20210301 20:21:02', '*', '8.164.x.x', 'aaa bbb ccc...', 'xxx xxx x x x x...']
最后,我受到了另一段我在源代码中保存了很久的代码的启发:
let test = "DATEADDED=20210301 20:21:02 IDENT=* IP=88.164.x.x REASON=aaa bbb ccc... NOTE=xxx xxx x x x x...";
let regex = /DATEADDED=(.*) IDENT=(.*) IP=(.*) REASON=(.*) NOTE=(.*)/g;
let out = regex.exec(test);
alert(out[1]); //20210301 20:21:02
alert(out[2]); //*
alert(out[3]); //88.164.x.x
alert(out[4]); //aaa bbb ccc...
alert(out[5]); //xxx xxx x x x x...
行之有效。问题解决了