我目前正在尝试使用javascript从自动警报中提取特定数据。根据设备的不同,数据可能会以3种方式显示。...
Thursday, August 2, 2018
无论如何,我想退出cWNotificationDescription = AP 'CC-PR555555' disassociated from Controller '111.11.111.11'.
OR.....
AP 'CC-PR555555' is being contained. This is due to rogue device spoofing or targeting AP 'CC-PR555555' BSSID on '802.11b/g' radio
OR.....
'802.11a/n' interface of AP 'CC-PR555555' associated to controller 'CC-AA-5555 (111.11.111.11)' is down.
。它们也可能显示为"CC-PR555555"
或"PR55:55:55:55:55:55"
,因此诀窍在于提取该确切位置中的任何数据,因为它们的长度可以不同。
它始终以AP开头,所需的数据在单引号''内,但是在所有警报中,单引号中都包含多个数据点,并且在警报之一中,所需的数据行被列出两次。
任何有关如何提取它的建议都是很棒的
答案 0 :(得分:0)
您可以使用RegEx查找所需的值,此简单的正则表达式将查找AP '
并接受下一个'
之前的所有内容
let sampleInput = ["cWNotificationDescription = AP 'CC-PR555555' disassociated from Controller '111.11.111.11", "AP 'CC-PR555555' is being contained. This is due to rogue device spoofing or targeting AP 'CC-PR555555' BSSID on '802.11b/g' radio", "'802.11a/n' interface of AP 'CC-PR555555' associated to controller 'CC-AA-5555 (111.11.111.11)' is down."]
var r = /(?<=AP\s')CC-[^']*(?=')/;
for(let i = 0; i < sampleInput.length; i++){
console.log("Found", r.exec(sampleInput[i])[0], "in", '"', sampleInput[i], '"');
}