Regex match alert message
Trying to match both these cases - (the bolded text): First, ends with ), second ends with the 1st colon.
sometext sometext Alert Message: \\SERVERNAME: TFTP service is down - no heartbeat. (\\SERVERNAME)
IP Address: 184.108.40.206 : Alert Message: device name is unreachable : Event Class: /Status/Ping : Site:
This works for 2nd , but not for 1st
.match(/Alert Message:.*? :/g)
What rx will match both cases?
You can use a pipe '|' to indicate an 'or' in a regular expression. Also you can use .*? to skim over unimportant parts of the text to look for sections that are important. Here is an example of both in effect: http://jsfiddle.net/985Kg/
var regex = new RegExp('(Alert Message.*?TFTP service is down - no heartbeat.|Alert Message: device name is unreachable)'); alert(regex.test('Alert Message: \\SERVERNAME: TFTP service is down - no heartbeat. (\\SERVERNAME)')); // alerts 'true'.
Try the following:
This is a lot more general, it might trigger false alarms.